我遍历Outlook中的所有电子邮件帐户。我可以得到POP和IMAP帐户的电子邮件地址,但我没有得到MS帐户的电子邮件地址。
这是我的代码:
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);
}以下是非交换帐户的结果:
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帐户的电子邮件地址。我怎么弄到这个?
发布于 2018-05-17 13:36:05
对于Exchange帐户,请使用account.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress。
发布于 2018-05-17 10:23:07
试试ExchangeService.ResolveName:
//ExchangeService service; //you have some service in your code.
NameResolutionCollection nameColl = service.ResolveName(CurrentUser.Name, ResolveNameSearchLocation.DirectoryOnly,true);稍微调整一下参数。
https://stackoverflow.com/questions/50388578
复制相似问题