繁体   English   中英

Outlook帐户-如何获取Exchange电子邮件地址?

[英]Outlook Accounts - How to get the Exchange Email address?

我遍历Outlook中的所有电子邮件帐户。 我可以获得POP和IMAP帐户的电子邮件地址,但没有MS Exchange帐户的电子邮件地址。

这是我的代码:

    foreach (Outlook.Account account in accounts) {
        Debug.Print("DisplayName: " + account.DisplayName);
        Debug.Print("UserName: " + account.UserName);
        Debug.Print("CurrentUser.Address: " + account.CurrentUser.Address); //email address or long Exchange address
        Debug.Print("CurrentUser.Name: " + account.CurrentUser.Name);
        Debug.Print("CurrentUser.AddressEntry.Address: " + account.CurrentUser.AddressEntry.Address);
        Debug.Print("DeliveryStore.DisplayName: " + account.DeliveryStore.DisplayName);
    }

以下是非Exchange帐户的结果:

DisplayName: Edgar Test Account
UserName: Edgar Tester
CurrentUser.Address: edgar@testtest.com
CurrentUser.Name: Edgar Tester
CurrentUser.AddressEntry.Address: edgar@testtest.com
DeliveryStore.DisplayName: Edgar Tester

对于交换:

DisplayName: User Name
UserName: 000300KJDFA6220
CurrentUser.Address: /O=FIRST ORGANIZATION/OU=EXCHANGE ADMINISTRATIVE GROUP(FYDIAASFDSFLT)/CN=RECIPIENTS/CN=00458787FA6220
CurrentUser.Name: /O=FIRST ORGANIZATION/OU=EXCHANGE ADMINISTRATIVE GROUP(FYDLKHHKLSPDLT)/CN=RECIPIENTS/CN=0054654DFA6220
CurrentUser.AddressEntry.Address: /O=FIRST ORGANIZATION/OU=EXCHANGE ADMINISTRATIVE GROUP(FYDIDADS23SPDLT)/CN=RECIPIENTS/CN=0058876220
DeliveryStore.DisplayName: User Name

(我更改了一些数字和字母以使其匿名化)

我想要Exchange帐户的电子邮件地址。 我怎么能得到这个?

对于Exchange帐户,请使用account.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress

试试ExchangeService.ResolveName

//ExchangeService service; //you have some service in your code.

NameResolutionCollection nameColl = service.ResolveName(CurrentUser.Name, ResolveNameSearchLocation.DirectoryOnly,true);

稍微调整一下参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM