0

I am trying to write a macro which would create an appointment in O365 group calendar.
I am able to create the appointment if the current folder is the group calender. However, I want the macro to always create the appointment for the group calendar, irrespective of the current folder. I have looked at other posts on accessing shared calendar and other subfolders under default calendar, but I am not able to find anything that works for a group calender.

I have tried these things:

    ' option1
  Set calFolder = GetFolderPath("abc@email.com\Calendars\groupname")
  Set NameSpace = Application.GetNamespace("MAPI")
  ' option 2
  Set calFolder = NameSpace.GetDefaultFolder(9).Folders("groupname")
  NameSpace.GetSharedDefaultFolder("groupemail", olFolderCalendar)
  Set Items = calFolder.Items
  ' option 3  
  Set Items = Application.Session.GetDefaultFolder(olFolderCalendar).Parent.Folders("groupname").Items

This is office 365 group. Lets call it abc. The group email is abc@somedoamin.com

In the folder structure it appear like this:

My Mailbox

-Groups

--abc

Appreciate any pointers. Thanks in advance!

EDIT: I found this structure for the group I am looking for in the debugger:

Namespace
|
AddressLists
|
|
Item 7 : Name: All groups
|
AddressEntries
|
Item 18: Name: abc

Is there a way I can use this information to get the folder?

Screenshot of structure under namespace

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
jingle123
  • 63
  • 8
  • Edit the question to apply this advice [mcve] – niton Aug 29 '18 at 23:57
  • Describe where the calendar appears in the folder tree. Perhaps a diagram similar to this. https://stackoverflow.com/questions/9076634/get-reference-to-additional-inbox – niton Aug 30 '18 at 00:40
  • Hi, This is office 365 group. Lets call it abc. The group email is abc@somedoamin.com In the folder structure it appear like this: My Mailbox- -Groups ---abc Also edited the question with this information. Thanks. – jingle123 Aug 30 '18 at 13:58

1 Answers1

0

You need to use GetSharedDefaultFolder, but its first argument is a Recipient object, not a string. Call Namespace.CreateRecipient (passing a string), then pass that Recipient object to GetSharedDefaultFolder.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Thanks for your quick response. I tried your approach. But now its giving me a runtime error: "The server mailbox cannot be opened because this address book entry is not a mail user" – jingle123 Aug 29 '18 at 21:42
  • Does the same name work in Outlook if you click "File | Open | Other User's Folder"? – Dmitry Streblechenko Aug 29 '18 at 21:46
  • Here you go. Exchange is telling you there is no mailbox that belongs to the specified name. Is that the name of a distribution list? – Dmitry Streblechenko Aug 30 '18 at 14:18
  • But it does have a mailbox. It has shared mailbox and has its own calendar too. Office 365 groups are different than distribution lists. I am able to send and receive emails and create events on this calendar. I have updated the question with the folder structure – jingle123 Aug 30 '18 at 14:25
  • 1
    Groups, even if they are exposed in the Outlook UI, are not (at least yet) exposed through OOM or even MAPI - on the MAPI level, there is a store, but it is not in the session stores table. – Dmitry Streblechenko Aug 30 '18 at 16:13
  • Ohh. Well that's a bummer! I will stick to my original code then. Thank you! – jingle123 Aug 30 '18 at 17:11