How to update Recurring Occurrences programmatically?

  • Thread starter Thread starter Maya
  • Start date Start date
M

Maya

Hi,
I wish to know if I can programmatically modify single occurrence of
a Recurring Activity in Outlook 2000 with Internet Mode?
I have gone through forums and found out that CDO MessageFilter can
be used for instantiating and modifying single occurrence.
Is there any other way to update such occurrence,like using MAPI?
Thanks in advance,
Maya
 
You can even do it using the Outlook object model. Each appointment or
task has an IsRecurring property, a GetRecurrencePattern method and a
RecurrenceState property. Once you have the RecurrencePattern you can
use its GetOccurrence method. Look in the Object Browser for more
information and code snippets for working with those properties and
methods.
 
Hi Ken,
Thanks for the quick reply. I am using the GetOccurrence Method from
the RecurrencePattern to obtain a Occurrence. But when I try to modify
any value of this Occurrence(like I am updating StartDate of the
Appointment), the control goes out of the project and the
application(project) closes down.
The code snippet is as follows:

_AppointmentItem parentObj;
LPDISPATCH lpParent = m_NamespaceObj.GetItemFromID(csGUID,(const
struct tagVARIANT)Temp);
if(lpParent)
parentObj.AttachDispatch(lpParent);
if(parentObj.m_lpDispatch){
RecurrencePattern recPatternObj;
LPDISPATCH lpRecurObj = parentObj.GetRecurrencePattern();
if(lpRecurObj)
recPatternObj.AttachDispatch(lpRecurObj);
if(recPatternObj.m_lpDispatch){
COleDateTime dtDate;
if(!csStartDate.IsEmpty())
dtDate.ParseDateTime(csStartDate);
if(dtDate.m_dt)
lpActivityDisp = recPatternObj.GetOccurrence(dtDate.m_dt);

recPatternObj.ReleaseDispatch();
}
parentObj.ReleaseDispatch();
}

The lpActivityDisp gives me the Correct Occurrence as per the Date
Specified.
But when I try the below code, it gives error. I am also unable to get
the error message too. It just closes the application and comes out.

_AppointmentItem aptItem;
aptItem.AttachDispatch(lpActivityDisp);
COleDateTime oleLocalTime;
oleLocalTime.SetDateTime(oleStartDate.GetYear(),
oleStartDate.GetMonth(), oleStartDate.GetDay(),
oleStartDate.GetHour(), oleStartDate.GetMinute(),
oleStartDate.GetSecond()); // oleStartDate contains the Date, which
we need to set the Start Date by.

AppmtItem.SetStart(oleLocalTime);
..
..
..

Please suggest, whether I am doing something wrong in Initiating the
Occurrence?

Thanks,
Maya
 
I don't do C code so I can't answer where your problem is. If you do
the code in VB/VBA you most certainly can set an AppointmentItem.Start
value. I would step the code and make sure you have valid references
to your items and properties as you go.
 
Thanks Ken. I am now able to update the Occurrence, the reference
which I was holding was invalid one.

Thanks once again,
Maya
 
Back
Top