4

I'm writing an application that displays a calendar; when you click a date on the calendar, it should display a window listing the appointments for that day.

How can this be done in VB.Net? I can find code to add appointments to a calendar, but not to do this.

Pickle
  • 1,064
  • 9
  • 33
  • 51

2 Answers2

0

Here is a snippet of code using the Outlook Interop API.

This piece of code reaches out to the application and fetches all calendar items. If you wish to restrict based on a date, you can call the clfFolder.Items.Restrict method and pass in a restriction filter. Please note, I call the clear recurrence items in this method to formalize entries as opposed to listing a single item with recurrence.

Dim appOutlook As Outlook.Application = Me.OutlookFormRegion.Application
Dim mpnNamespace As Outlook.NameSpace = appOutlook.GetNamespace("MAPI")
Dim clfFolder As Outlook.Folder = _ 
    mpnNamespace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar)
Dim itmItems As Outlook.Items
Dim oaiAppointmentItem As Outlook.AppointmentItem
clfFolder.Items.IncludeRecurrences = False
For Each oaiAppointmentItem In clfFolder.Items
    oaiAppointmentItem.ClearRecurrencePattern()
Next
Mike Calvert
  • 131
  • 7
  • Dim appOutlook As Outlook.Application = Outlook.FormRegion.Application gives me "Reference to a non-shared member requires an object reference." – Pickle May 09 '12 at 20:04
0

I used this to find the data. not sure if will help

Try

        Dim olApp As Outlook.Application
        olApp = CreateObject("Outlook.Application")
        Dim mpnNamespace As Outlook.NameSpace = olApp.GetNamespace("MAPI")
        Dim oCalendar As Outlook.MAPIFolder = mpnNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
        Dim oItems As Outlook.Items = oCalendar.Items
        oItems.Sort("Start")
        oItems.IncludeRecurrences = True
        Dim oAppt As Outlook.AppointmentItem = oItems.Find("[Subject] = 'Upgrade/Issue reported via eData - Ref:2'")
        oAppt.Subject = "Updated"
        oAppt.Save()
        olApp = Nothing
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
Anthon
  • 69,918
  • 32
  • 186
  • 246