Place apponinments to alternate calendar. RRS feed

  • Question

  • I am trying to create appointments in a secondary calendar in outlook. I have created a form that lets the use enter information for an appointment but I want them to be able to save it in a shared calendar rather than their default outlook calendar. I found code that will create the appointment in my default calendar but I do not know how to reference the alternate calendar. Does anyone have code that lets you change from one calendar to another when creating an appointment.

    Eric Roberts

    I forgot to mention, I am coding in VBA.
    • Edited by Eric.Rob98 Thursday, June 19, 2014 10:51 AM
    Thursday, June 19, 2014 10:50 AM

All replies

  • Hello Eric,

    To get your "local" calendar you can use the following methods:

    Store.GetDefaultFolder - returns a Folder object that represents the default folder in the store and that is of the type specified by the FolderType argument.

    NameSpace.GetDefaultFolder - returns a Folder object that represents the default folder of the requested type for the current profile, for example, obtains the default Calendar folder for the user who is currently logged on. 

    But to get a shared calendar you need to use the NameSpace.GetSharedDefaultFolder method which returns a Folder object that represents the specified default folder for the specified user which you should specify explicitly. Also the NameSpace.OpenSharedFolder method can be used for accessing a shared folder referenced through a URL or file name.

    For example, MSDN provides the following sample code:
    Sub ResolveName()  
     Dim myNamespace As Outlook.NameSpace  
     Dim myRecipient As Outlook.Recipient  
     Dim CalendarFolder As Outlook.Folder 
     Set myNamespace = Application.GetNamespace("MAPI")  
     Set myRecipient = myNamespace.CreateRecipient("Dan Wilson")  
     If myRecipient.Resolved Then  
     Call ShowCalendar(myNamespace, myRecipient)  
     End If  
    End Sub 
    Sub ShowCalendar(myNamespace, myRecipient)  
     Dim CalendarFolder As Folder 
     Set CalendarFolder = _  
     myNamespace.GetSharedDefaultFolder _  
     (myRecipient, olFolderCalendar)  
    End Sub

    Thursday, June 19, 2014 10:59 AM