Quantcast
Channel: VBForums - COM and ActiveX
Viewing all articles
Browse latest Browse all 62

Removing appointment items in Outlook Calendar via VB 2010

$
0
0
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.

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

Please advise how much further I can modify this code to accomplish the task. Thanks. :)

Viewing all articles
Browse latest Browse all 62

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>