Download the Exchange server and email address in .NET.

H I. I would like to know the address of my Exchange server user (assuming that it is on a regular Windows office network). This is a C # application.


I already have the user's email address, I found it in System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress after linking to System.DirectoryServices.AccountManagement

+4
source share
3 answers

I use this for my Exchange client application.

  • Install the Managed Web Services API .
  • Change your C # project. Properties / Application changed the target structure to ".NET Framework 4" and not ".NET 4 Client Profile".
  • Link C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll

Now the code:

 var exchange = new ExchangeService(); exchange.AutodiscoverUrl(from); var server = exchange.Url.Host; Console.WriteLine(server); 

Here is the MSDN documentation . but pay attention to the unreleased version 1.2 of the API. I can not find documentation for version 1.1

+2
source

You are looking for an AD attribute called homeMDB: http://msdn.microsoft.com/en-us/library/ms980583(v=exchg.65).aspx

I don’t think there is a good .NET wrapper for this attribute, so to get it you need a lower level LDAP API.

Note that with later versions of Exchange (such as 2010), you can connect to any CAS role, and Exchange will determine the routing.

+1
source
+1
source

Source: https://habr.com/ru/post/1401422/


All Articles