Results 1 to 2 of 2

Thread: Removing appointment items in Outlook Calendar via VB 2010

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    5

    Removing appointment items in Outlook Calendar via VB 2010

    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.

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    5

    Re: Removing appointment items in Outlook Calendar via VB 2010

    Can someone please answer?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width