0

I want to user GetCalendarExporter() on contact folder of shared calendar.

I have written code which I feel will give only default calendar folder(i.e. Owner's calendar folder). I want Shared(Delegated) Calendar folder object/pointer. Any idea how to do that?

As of now my code is like:


CComPtr<Olk::_NameSpace> spNameSpace = spApplication->GetNamespace(L"MAPI");

Olk::MAPIFolderPtr spCalFolder = spNameSpace->GetDefaultFolder(Olk::olFolderCalendar);

spCalFolder->GetCalendarExporter();

1 Answers1

0

You need to use the NameSpace.GetSharedDefaultFolder method which returns a Folder object that represents the specified default folder for the specified user. This method is used in a delegation scenario, where one user has delegated access to another user for one or more of their default folders (for example, their shared Calendar folder).

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("Eugene Astafiev") 
 myRecipient.Resolve 
 If myRecipient.Resolved Then 
   Call ShowCalendar(myNamespace, myRecipient) 
 End If 
End Sub 
 
Sub ShowCalendar(myNamespace, myRecipient) 
 Dim CalendarFolder As Outlook.Folder 
 Set CalendarFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderCalendar) 
 CalendarFolder.Display 
End Sub
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Hi Eugene Astafiev, Thanks for your answer. Just one question, GetSharedDefaultFolder() requires recipient to be resolved and passed as input parameter. What if I don't have recipient? What I want to do is. Want to apply CalendarFolder->GetCalendarExporter(); Where CalendarFolder is Shared folder. – Mahesh Amarelia Jun 12 '21 at 05:37
  • You must know the person who has shared the calendar to get the calendar folder. Use the [CreateRecipient](https://learn.microsoft.com/en-us/office/vba/api/outlook.namespace.createrecipient) method to create a recipient object. – Eugene Astafiev Jun 12 '21 at 17:37
  • Thanks Eugene Astafiev – Mahesh Amarelia Jun 18 '21 at 11:05