Listing the names of shared mailboxes with which you can access using the EWS Managed API

I set up a shared mailbox and can access it and its subfolders:

var folderId = new FolderId(WellKnownFolderName.MsgFolderRoot, "shared.mailbox@domain.local"); var folders = client.FindFolders(folderId, new FolderView(Int32.MaxValue)); 

To do this, I need to know the name of the shared mailbox - in this example, the name of the shared mailbox is shared.mailbox@domain.local . Is there a way to list all the names of the shared mailboxes that I have access to? I tried searching on the internet, but I could not find a solution.

+1
c # exchange-server exchangewebservices
source share
2 answers

when you, for example, connect to your Office 365 account from Exchange and join a group, you see the group’s shared mailbox. When you then view your Office 365 inbox online, not in Exchange, you also see this group,

If your Office365 group you are talking about, you can access it through GetUserUnifiedGroups in the latest version of the managed API from git hub https://github.com/OfficeDev/ews-managed-api eg

  RequestedUnifiedGroupsSet Group = new RequestedUnifiedGroupsSet(); Group.FilterType = UnifiedGroupsFilterType.All; Group.SortDirection = SortDirection.Ascending; Group.SortType = UnifiedGroupsSortType.DisplayName; List<RequestedUnifiedGroupsSet> reqG = new List<RequestedUnifiedGroupsSet>(); reqG.Add(Group); Collection<UnifiedGroupsSet> ugGroupSet = service.GetUserUnifiedGroups(reqG,"jcool@domain.com"); foreach (UnifiedGroupsSet ugset in ugGroupSet) { foreach (UnifiedGroup ugGroup in ugset.Groups) { Console.WriteLine(ugGroup.SMTPAddress); } } 

Mailboxes that allow access to where automatic matching is enabled (these are mailboxes that Outlook automatically displays in profile), for example, Add-MailboxPermission -AutoMapping can be opened using autodiscover, for example

 AutodiscoverService adAutoDiscoverService = new AutodiscoverService(ExchangeVersion.Exchange2013_SP1); adAutoDiscoverService.Credentials = new NetworkCredential("user@domain.com", "pass"); adAutoDiscoverService.EnableScpLookup = false; adAutoDiscoverService.RedirectionUrlValidationCallback = adAutoDiscoCallBack; adAutoDiscoverService.PreAuthenticate = true; adAutoDiscoverService.KeepAlive = false; GetUserSettingsResponse gsp = adAutoDiscoverService.GetUserSettings("user@domain.com", UserSettingName.AlternateMailboxes); Object Mailboxes = null; if (gsp.Settings.TryGetValue(UserSettingName.AlternateMailboxes, out Mailboxes)) { foreach (AlternateMailbox Mailbox in ((AlternateMailboxCollection)Mailboxes).Entries) { Console.WriteLine(Mailbox.SmtpAddress); } } 

However, the mailboxes in which you just added rights to the Mailbox or Mailbox do not know this, and then list each of the DACL mailboxes and check it.

+2
source share

Run this command in EMS to find all user mailbox names and export them to csv:

Get-Mailbox -ResultSize Unlimited | Select Name, Alias, RecipientTypeDetails | Export-Csv c: \ Users.csv

Then generate your code, read the file form and pass through them. I would recommend storing the folder in the dictionary so that you can access it later

And there is no way to find mailboxes on the server that directly form the api currently

+1
source share

All Articles