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 帐户的电子邮件地址。我怎样才能得到这个?
尝试 ExchangeService.ResolveName :
//ExchangeService service; //you have some service in your code.
NameResolutionCollection nameColl = service.ResolveName(CurrentUser.Name, ResolveNameSearchLocation.DirectoryOnly,true);
稍微调整一下参数。
对于 Exchange 帐户,使用 account.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress
。
我遍历了 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 帐户的电子邮件地址。我怎样才能得到这个?
尝试 ExchangeService.ResolveName :
//ExchangeService service; //you have some service in your code.
NameResolutionCollection nameColl = service.ResolveName(CurrentUser.Name, ResolveNameSearchLocation.DirectoryOnly,true);
稍微调整一下参数。
对于 Exchange 帐户,使用 account.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress
。