gpt4 book ai didi

c# - 枚举您可以使用 EWS 托管 API 访问的共享邮箱名称

转载 作者:行者123 更新时间:2023-11-30 15:20:55 28 4
gpt4 key购买 nike

我设置了共享邮箱并可以访问它及其子文件夹:

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

为此,我需要知道共享邮箱的名称 - 在此示例中,共享邮箱的名称是 shared.mailbox@domain.local。有没有办法枚举我可以访问的所有共享邮箱名称?我曾尝试在线搜索,但找不到解决方案。

最佳答案

when you for example connect to an Office 365 account from Exchange and join a group, you see the shared mailbox of that group. When you then browse to your Office 365 mailbox online and not in Exchange, you see that group there as well,

如果您谈论的是 Office365 组,您可以通过来自 git hub https://github.com/OfficeDev/ews-managed-api 的最新版托管 API 中的 GetUserUnifiedGroups 访问这些组例如

        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);
}
}

授权访问启用自动映射的邮箱(这些是 Outlook 将自动映射到配置文件中的邮箱)例如 Add-MailboxPermission -AutoMapping 可以使用自动发现例如发现

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);
}
}

然而,您刚刚将权限添加到邮箱或文件夹的邮箱无法知道其他邮箱,然后枚举每个邮箱 DACL 并进行检查。

关于c# - 枚举您可以使用 EWS 托管 API 访问的共享邮箱名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38881919/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com