Frano Rezo
Frano Rezo

Reputation: 1

How to get distribution list (not group) with its members inside the Outlook using the OfficeJS or Graph API?

I'm trying to get the distribution list of people/members inside the Outlook add-in.

That distribution/contact list is not the "group" as it was created inside the "Outlook People" section using the option to create "New contact list" as described on the image below:

contact-list

I can see that list is created and listed at "Your contact lists" like on the following image:

your-contact-lists

And it can be added as the recipient in the mail as can be seen on the next image:

recipient-contact-list

But I couldn't find a proper API for getting that data neither using the OfficeJS nor the Graph API. I saw some suggestions to fetch the "groups" using the Graph API endpoint: https://graph.microsoft.com/v1.0/groups, but once again, this is only a (distribution) list of contacts, not a group.

I'd appreciate it if someone from the MSFT team has a suggestion on how to solve this by providing a solution for getting 3 things:

  1. Get the list of distribution/contact lists
  2. Get the members of a specific contact list
  3. Check if the recipient has a mail or is just a contact list without a mail

Thanks 😊

Upvotes: 0

Views: 1496

Answers (2)

Abhishek Mendon
Abhishek Mendon

Reputation: 21

We used graph api GET /groups/{id}/members endpoint.

We added below permissions:

  • Group.Read.All
  • GroupMember.Read.All
  • User.ReadBasic.All
  • OrgContact.Read.All <- this might not be needed unless you have contacts in your distro list.

Upvotes: 0

CodeNewbie
CodeNewbie

Reputation: 53

I up your question as I'm also looking for the answer to your question, unfortunately I do not have enough reputation to increase the up value. Not sure if you have come to a solution?

I understand that you mentioned that the 'groups' here does not imply 'Memberships' in Outlook. Just wondering if you have tested the API and come to this conclusion? I tried this Graph Explorer, however I have permission issues so I could not verify.

Get the members of a specific contact list
https://learn.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http

Get the list of distribution/contact lists
https://learn.microsoft.com/en-us/graph/api/user-list-memberof?view=graph-rest-1.0&tabs=http

If 'distribution list' is 'contacts' under contacts folder as suggested by MSFT, will the following API work?
https://learn.microsoft.com/en-us/graph/api/user-list-contacts?view=graph-rest-1.0&tabs=http

Thanks!

Upvotes: 0

Related Questions