Editing Outlook Task/Appt from Access VBA

ScottGem

Registered User.
Local time
Yesterday, 19:53
Joined
Jun 20, 2005
Messages
1,119
I've been searching for this and haven't found it. I have the code to create either a Task or appointment from within an Access module. Works great. But I want to be able to update the item if changes are made within Access. For example: if a task is marked complete in the Access database, I want to update that task and mark it complete in Outlook. Or if the appt date & time are changed, likewise.

So how do I retrieve the Outlook Item (most concerned with Tasks) so I can then modify it? I can capture the EntryID when I create the task, can I use that?
 
I would suggest that you use one of the properties of a TaskItem or Appointment item - for example I use "mileage" when I create my Appointmentitem i give the mileage my unique code. The reason for this is if someone changes the Appointmentitem in outlook then the ID will change but the mileage will not.

I am pretty sure that to find an item (Email, task or Appointment for eg) you use the FIND method. I think there is also a RESTRICT method which will return a collection of items which you can then search through eg between two dates.

Because I use the mileage property I can use the FIND method and your result is either true or false.

My example below is to find an appointmentitme of a delegates calendar, I could not find a simple example but I think you will get the drift. The only thing you will have to change is the "GetSharedDefaultFolder" to get your taks item.

objApp is your Outlook Application object.

Code:
Set objNS = objApp.GetNamespace("MAPI")

'strName is the email address of the persons calendar I want to search in
'as i said this is used for delegated calendars but I think that it will also
'work if you use your own calendar.
Set objRecip = objNS.CreateRecipient(strName)

'here is the important but you will need to get either the USERS calendar
'or get the tasks folder
Set objFolder = objNS.GetSharedDefaultFolder(objRecip, olFolderCalendar)

'app_CalendarID is my unique ID that I injected into the Mileage property of
'the appointment item
sFilter = "[Mileage] = " & app_CalendarID & ""

'this is the real part of the code which finds the item and depending on how 
'many items you have might take some time.
'in my case objAppt is an Outlook.AppointmentItem
Set objAppt = objFolder.Items.Find(sFilter)
I think you know that objAppt will then be your AppointmentItem from which you can read - .Start .End etc.

Here for your referencehttp://msdn.microsoft.com/en-au/library/aa220093(office.11).aspx

and

http://msdn.microsoft.com/en-au/library/aa210275(office.11).aspx
 
Thanks Darbid,

That was enough to get me to the right place and successfully do what I wanted. Appreciate the help.

Scott<>
 

Users who are viewing this thread

Back
Top Bottom