获取.NET用户的Exchange服务器和电子邮件地址
H I。我想知道我的用户的Exchange服务器的地址(假设她是一个典型的Windows办公网络)。这是一个C#应用程序。
Hi. I would like to know the address of my user's Exchange server (assuming she's in a typical Windows office network). This is in a C# application.
我已经有用户的电子邮件地址,我发现它在 System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress
,引用后的 System.DirectoryServices.AccountManagement 的
I already have the user's email address, I found it at System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress
, after referencing System.DirectoryServices.AccountManagement
我用这对我的Exchange客户端应用程序。
I use this for my Exchange client application.
- 在安装 Exchange Web服务托管API 一>
- 在改变你的C#项目的属性/应用改变了目标框架为.NET Framework 4的'不'.NET 4客户端配置文件
- 参考
C:\ Program Files文件\微软\交易所\ Web服务\ 1.1 \ Microsoft.Exchange.WebServices.dll
- Install Exchange Web Services Managed API
- Change your C# project's Properties/Application changed the target framework to '.NET Framework 4' not '.NET 4 Client Profile'
- Reference
C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll
现在code:
var exchange = new ExchangeService();
exchange.AutodiscoverUrl(from);
var server = exchange.Url.Host;
Console.WriteLine(server);
这里是 MSDN文档 。但需要注意的是该API的未发行的1.2版本。我无法找到文档1.1版本
Here's the MSDN documentation. but note it's for the unreleased version 1.2 of the API. I can't locate the documentation for version 1.1