Shezad Ahmed
asked on
Update Outlook Appointment
Hi all
I am using the code below to search for all appointments after a certain date. Then I want to update the Categories of the appointments.
The problem is it adds a new appointment instead of Updating an existing one.
Any help highly appreciated.
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objAppt = objOutlook.CreateItem(olAp pointmentI tem)
Dim ol As Object
Dim olns As Object
Dim objFolder As Object
Dim objAllAppoint As Object
Dim Appoint As Object
' Set the application object
Set ol = New Outlook.Application
' Set the namespace object
Set olns = ol.GetNamespace("MAPI")
' Set the default Calendar folder
Set objFolder = olns.GetDefaultFolder(olFo lderCalend ar)
Set objAllAppoint = objFolder.Items
' Loop through each Appointment
Dim st As String
Dim dt As Date
For Each Appoint In objAllAppoint
st = Format(Appoint.Start, "dd-mm-yyyy")
dt = "01-01-2004"
If st > dt Then
objAppt.Categories = "Processed"
objAppt.Save
End if
Next
End Sub
I am using the code below to search for all appointments after a certain date. Then I want to update the Categories of the appointments.
The problem is it adds a new appointment instead of Updating an existing one.
Any help highly appreciated.
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Appl
Set objAppt = objOutlook.CreateItem(olAp
Dim ol As Object
Dim olns As Object
Dim objFolder As Object
Dim objAllAppoint As Object
Dim Appoint As Object
' Set the application object
Set ol = New Outlook.Application
' Set the namespace object
Set olns = ol.GetNamespace("MAPI")
' Set the default Calendar folder
Set objFolder = olns.GetDefaultFolder(olFo
Set objAllAppoint = objFolder.Items
' Loop through each Appointment
Dim st As String
Dim dt As Date
For Each Appoint In objAllAppoint
st = Format(Appoint.Start, "dd-mm-yyyy")
dt = "01-01-2004"
If st > dt Then
objAppt.Categories = "Processed"
objAppt.Save
End if
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.