title: How to get the domain name programmatically in Microsoft Exchange Services
body: <p>I was using Outlook COM component to create an appointment, but it was causing many problems on IIS related to security, etc. So, I am using the Microsoft Exchange Services dll.</p>
  
  <p>In the following code, I have to give the domain name, which I don't want to do, because it will be different for every client.</p>
  
  <pre><code>ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
      service.Credentials = new WebCredentials("username", "password");
      service.AutodiscoverUrl("username@domain.com");
  </code></pre>
  
  <p>The other thing is, when adding an Attendee during appointment creation, I have to again give the complete email address of a user like username@domain.com; I want to use only the username.</p>