Question OUTlook Addin - Appointment data capture

fullyii

Member
Joined
Aug 19, 2005
Messages
22
Location
Chicago
Programming Experience
1-3
Visual Studio 2010
Outlook 2007

I am currently extracting all the appointments for a given time period from a calendar in my outlook. I have another outlook user create an alternate calendar and grant me access to the calendar. I can see the calendar in my outlook. I want to be able to grab the appointment details from this users calendar.

Can you please help me out with access the appointment data from another users calendar?


VB.NET:
    Sub FindApptsInTimeFrame()
        Dim myStart, myEnd As Date
        Dim oCalendar As Outlook.Folder
        Dim oItems As Outlook.Items
        Dim oResItems As Outlook.Items
        Dim oAppt As Outlook.AppointmentItem
        Dim strRestriction As String
        Dim ClientManger As String = ""
        Dim Lob As String = ""
        Dim WRNumber As String = ""
        Dim wrTitle As String = ""
        Dim ReportNumber As String = ""
        Dim ReportTitle As String = ""
        Dim Category_Form As String = ""
          


        'Hard-code the reporting dates just for simplicity in testing.
        myStart = DateValue("11/24/2013")
        myEnd = DateValue("12/07/2013")


        Dim olFolderCalendar As OlDefaultFolders = OlDefaultFolders.olFolderCalendar

        oCalendar = Application.Session.GetDefaultFolder(olFolderCalendar)
        [COLOR="#FF0000"]oCalendar.Application.Session.Logon("User,Name", , True, True)[/COLOR]             'This line is not working.
        oItems = oCalendar.Items
        oItems = Application.Session.GetDefaultFolder(olFolderCalendar).Items.Parent.Folders("RUIT").Items




        'Include all recurring calendar items -
        'master appointments as well as recurring appointments.
        oItems.IncludeRecurrences = True
        oItems.Sort("[Start]")

        'Specify the filter this way to include appointments that overlap
        'with the specified date range but do not necessarily fall entirely within
        'the date range.
        'Date values in filter do not explicitly include minutes.
        strRestriction = "[Start] <= '" & myEnd _
        & "' AND [End] >= '" & myStart & "'"


        'Restrict the Items collection.
        oResItems = oItems.Restrict(strRestriction)
        'Sort
        oResItems.Sort("[Start]")

        'Reformat myStart and myEnd to account for minutes.
        myStart = #11/24/2013 12:59:00 AM#
        myEnd = #12/7/2013 11:59:59 PM#



        For Each oAppt In oResItems

      
            ' Test Data output' 

            Debug.Print("EntryID " & oAppt.EntryID)
            Debug.Print("GlobalAppointmentID: " & oAppt.GlobalAppointmentID)
            Debug.Print("User: " & oItems.Session.CurrentUser.Name)
            Debug.Print("Profile Name: " & oItems.Session.CurrentProfileName)
            Debug.Print("Category: " & oAppt.Categories)
            Debug.Print("Subject: " & oAppt.Subject)
            Debug.Print("Title: " & oAppt.Location)
            Debug.Print("Time: " & oAppt.Duration / 60)
            Debug.Print("Form: " & oAppt.FormDescription.DisplayName)
            Debug.Print("Caption: " & oAppt.GetInspector.Caption)
            Debug.Print("Create Time: " & oAppt.CreationTime)
            Debug.Print("Start Date UTC: " & oAppt.StartUTC)
            Debug.Print("End Date UTC: " & oAppt.EndUTC)
            Debug.Print("Start: " & oAppt.Start)
            Debug.Print("End: " & oAppt.End)
            Debug.Print("Body: " & oAppt.Body)
            Debug.Print("StartofWeek: " & myStart)
            Debug.Print("EndofWeek: " & myEnd)
            Debug.Print("LastModificatioinTime: " & oAppt.LastModificationTime)

            If oAppt.FormDescription.DisplayName <> "RUIT - Appointments" Then
                Debug.Print("Client Manager: NA")
                ClientManger = "NA"
            Else : Debug.Print("Client Manager: " & oAppt.UserProperties("ClientManger").Value())
                ClientManger = oAppt.UserProperties("ClientManger").Value()
            End If


            If oAppt.FormDescription.DisplayName <> "RUIT - Appointments" Then
                Debug.Print("LOB: NA")
                Lob = "NA"
            Else : Debug.Print("LOB: " & oAppt.UserProperties("Lob").Value())
                Lob = oAppt.UserProperties("Lob").Value()
            End If

            If oAppt.FormDescription.DisplayName <> "RUIT - Appointments" Then
                Debug.Print("WRNumber: NA")
                WRNumber = "NA"
            Else : Debug.Print("WR#: " & oAppt.UserProperties("WRNumber").Value())
                WRNumber = oAppt.UserProperties("WRNumber").Value()
            End If


            If oAppt.FormDescription.DisplayName <> "RUIT - Appointments" Then
                Debug.Print("Wr Title: NA")
                wrTitle = "NA"
            Else : Debug.Print("Wr Title: " & oAppt.UserProperties("wrTitle").Value())
                wrTitle = oAppt.UserProperties("wrTitle").Value()
            End If

            If oAppt.FormDescription.DisplayName <> "RUIT - Appointments" Then
                Debug.Print("Report Number: NA")
                ReportNumber = "NA"
            Else : Debug.Print("Report Number: " & oAppt.UserProperties("ReportNumber").Value())
                ReportNumber = oAppt.UserProperties("ReportNumber").Value()
            End If

            If oAppt.FormDescription.DisplayName <> "RUIT - Appointments" Then
                Debug.Print("Report Title: NA")
                ReportTitle = "NA"
            Else : Debug.Print("Report Title: " & oAppt.UserProperties("ReportTitle").Value())
                ReportTitle = oAppt.UserProperties("ReportTitle").Value()
            End If

            If oAppt.FormDescription.DisplayName <> "RUIT - Appointments" Then
                Debug.Print("Category_Form: NA")
                Category_Form = "NA"
            Else : Debug.Print("Category_Form: " & oAppt.UserProperties("cmbCategory").Value())
                Category_Form = oAppt.UserProperties("cmbCategory").Value()

            End If

            Debug.Print("-------------------------------------------------------- ")
        Next


    End Sub
 
Top Bottom