How to find Appointment Item by EntryID?
It sounds like you want to change the Categories value for all the
occurrences in a series - is that right? In that case you need to make the
change to the recurrence master. I assume from your description that "olai"
is obtained by iterating through an Items collection where
IncludeRecurrences = True.
Dim apptMaster as AppointmentItem
If olai.IsRecurring Then
Select Case olai.RecurrenceState
Case olApptMaster
'this is the recurrence master
'set Categories value here (if necessary)
If olai.Categories strCategoryName Then
olai.Categories = strCategoryName
olai.Save
End If
Case olApptOccurrence
'this is just a regular occurrence in the series
'don't make a change here or you will make this an exception
'all occurrences in the series will have the same EntryID value
'calling GetItemFromID with that value will return the
recurrrence master
Set apptMaster = olns.GetItemFromID(olai.EntryID)
If apptMaster.CategoriesstrCategoryName Then
apptMaster.Categories = strCategoryName
apptMaster.Save
End If
Case olApptException
'this is an exception to the series
'it can have property values that are different from the master
If olai.CategoriesstrCategoryName Then
olai.Categories = strCategoryName
olai.Save
End If
Case Else
'the other possible value is olApptNotRecurring, which won't be
returned if IsRecurring = True
End Select
End If
"deko" wrote in message
...
When looping through a collection of Outlook.Items that includes
recurrences, and a recurring appointment is found, I need to get the
non-recurring appointment in order to change the Categories property.
I want to eliminate the the Do loop below and go directly to the
appointment item in question. I can minimize the iterations of the loop
by restricting the olRitms collection with strFilter, but there must be a
way to get the item by EntryID (?) Any suggestions appreciated...
For Each outlook appointment item including recurrences...
If olai.IsRecurring Then
strEntryID = olai.EntryID
Set olRitms = olns.GetDefaultFolder(olFolderCalendar).Items
Set objRcr = olRitms.Restrict(strFilter)
Do While i objRcr.Count
i = i + 1
If objRcr(i).EntryID = strEntryID Then
objRcr(i).Categories = strCategoryName
objRcr(i).Save
End If
Loop
End If
Next
|