简体   繁体   English

Outlook VSTO中CurrentUser.Address的电子邮件地址格式不正确

[英]Incorrect format of email address from CurrentUser.Address in Outlook VSTO

I am trying to get the current user's Outlook email address with 我正在尝试获取当前用户的Outlook电子邮件地址,

 Globals.ThisAddIn.Application.Session.CurrentUser.Address;

The value this displays is somewhat like this: 显示的值有点像这样:

"/o=ExchangeLabs/ou=Exchange Administrative Group (xxxxxxxxx)/cn=Recipients/cn=xxxxxxxxxxxxxxxxx-[the beginning of my email address is here]" “ / o = ExchangeLabs / ou = Exchange管理组(xxxxxxxxx)/ cn =收件人/ cn = xxxxxxxxxxxxxxxxxxxx- [我的电子邮件地址的开头在这里]”

The first problem is that the email address is cut off. 第一个问题是电子邮件地址被切断。 I at first thought that this is a breakpoint issue, but after modifying the string I found it's just cut off by default. 起初我以为这是一个断点问题,但是在修改了字符串之后,我发现默认情况下它只是被切断了。 The second is that I only want the email address value without all the data before. 第二个是我只希望之前没有所有数据的电子邮件地址值。 I could edit out the string but I'm looking for the proper way of getting the value. 我可以编辑出字符串,但是我正在寻找获取值的正确方法。

This works when the user logs in via Exchange. 当用户通过Exchange登录时,此功能有效。

Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress;

I'm looking for the equivalent for users not logged in via Exchange. 我正在为未通过Exchange登录的用户寻找等效项。

I found Email Address of the Current User but it is an old thread and the solutions all seem pretty hacky. 我找到了“当前用户的电子邮件地址”,但这是一个旧线程,解决方案似乎都非常笨拙。

Check the AddressEntry.Type property. 检查AddressEntry.Type属性。 If it is "EX", use GetExchangeUser().PrimarySmtpAddress . 如果它是“ EX”,请使用GetExchangeUser().PrimarySmtpAddress Otherwise just read the Address property. 否则,只需阅读Address属性。

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

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