Hi guys,
I'm not sure if this is the right section of the forum to ask for this help but here goes anyway. I am creating a WPF window that would take two date values and checks whether already allocated annual leave appointments have been set to and in between those two dates in Outlook calendar. The dates are input via DatePicker controls, one for the start date, the other for end date. If they do exist, I wish to remove those appointments. This is the code I have so far. Please note that it is far from accurate or complete and clearly needs bits and pieces which are missing.
Please advise how much further I can modify this code to accomplish the task. Thanks. :)
I'm not sure if this is the right section of the forum to ask for this help but here goes anyway. I am creating a WPF window that would take two date values and checks whether already allocated annual leave appointments have been set to and in between those two dates in Outlook calendar. The dates are input via DatePicker controls, one for the start date, the other for end date. If they do exist, I wish to remove those appointments. This is the code I have so far. Please note that it is far from accurate or complete and clearly needs bits and pieces which are missing.
Code:
Public Sub RemoveLeave(fromDate As Date)
Dim tempApp As New Microsoft.Office.Interop.Outlook.Application
Dim calendar As Outlook.MAPIFolder = _
tempApp.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Dim calendarItems As Outlook.Items = calendar.Items
Dim item As Outlook.AppointmentItem = TryCast( _
calendarItems("Test Appointment"), Outlook.AppointmentItem)
Dim pattern As Outlook.RecurrencePattern = _
item.GetRecurrencePattern()
Dim itemDelete As Outlook.AppointmentItem = _
pattern.GetOccurrence(New Date(fromDate))
If itemDelete IsNot Nothing Then
itemDelete.Delete()
End If
End Sub
End Class