Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 260854 - Last Review: July 15, 2004 - Revision: 2.4
How To VC: Detect Deleted Appointments in a Recurring Series with Outlook Object Model
This article was previously published under Q260854
This article demonstrates how to use Microsoft Visual C++ with Microsoft Outlook Object Model to programmatically detect a deleted appointment occurrence in a recurring series.
The following sample code works with recurring appointments by using the
RecurrencePattern object and the
Exceptions collection.
void IsApptDeleted()
{
_AppointmentItemPtr spAppointment;
RecurrencePatternPtr spRecurrence;
ExceptionsPtr spExceptions;
ExceptionPtr spException;
char s[200];
int k;
_ApplicationPtr spApp("Outlook.Application");
_NameSpacePtr pMAPI = spApp->GetNamespace("MAPI");
pMAPI->Logon();<BR/>
// Get the calendar folder.
MAPIFolderPtr spFolder = pMAPI->GetDefaultFolder(olFolderCalendar);
_ItemsPtr spItems = spFolder->GetItems();
k = sprintf(s, "Item Count: %d\n", spItems->Count);
OutputDebugString(s);
spItems->Sort("[Start]");
spItems->IncludeRecurrences = true;<BR/>
// Call Find to quickly check for the existence of an appointment.
spAppointment = spItems->Find("[Start] = ""01/13/2000 10:00""");
if (spAppointment == NULL) {
OutputDebugString("Find: Occurance has been deleted?");
}
// Iterate through all the appointments checking for deleted occurrences.
if (spItems->Count > 0) {
for (long i = 1; i <= spItems->Count; ++i) {
spAppointment = spItems->Item(i);
if (spAppointment != NULL) {
OutputDebugString(spAppointment->Subject);
OutputDebugString("\n");
if (spAppointment->IsRecurring == TRUE) {
OutputDebugString(" Recurring Appointment");
spRecurrence = spAppointment->GetRecurrencePattern();
// Get Exceptions collection of RecurrencePattern object.
spExceptions = spRecurrence->Exceptions;
if (spExceptions->Count > 0) {
for (long j = 1; j <= spExceptions->Count; ++j) {
spException = spExceptions->Item(j);
if (spException->Deleted == TRUE)
OutputDebugString(" Deleted");
else
OutputDebugString(" Not Deleted");
spException = NULL;
} // for loop j
} // exceptions count > 0
spExceptions = NULL;
spRecurrence = NULL;
} //If recurring...
spAppointment->Close(olDiscard);
} // is null
else {
OutputDebugString("NULL Appointment\n");
} // is null
spAppointment = NULL;
// Set a limit to avoid recurring appointments with no end date.
if (i > 50000)
break;
} // for loop
} // count > 0
spItems = NULL;
spFolder = NULL;
pMAPI->Logoff();
pMAPI = NULL;
spApp = NULL;
)
}
For information on how to work with Outlook Object Model in a Visual C++ project, see the following article in the Microsoft Knowledge Base:
259298Â
(http://kbalertz.com/Feedback.aspx?kbNumber=259298/EN-US/
)
How To Use Microsoft Outlook Object Model From Visual C++ Through an #IMPORT Statement
APPLIES TO
- Microsoft Outlook 2000 Standard Edition
- Microsoft Outlook 98 Standard Edition
| kbhowto kbmsg kboutlookobj KB260854 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate