title: Connecting to Exchange without AutoDiscover?
body: <p>I need to set up a custom application at my workplace, to read email subject lines from a specific Exchange Server mailbox, and redirect them based on the content. I wrote the following code to test connectivity:</p>
  
  <pre><code>using System;
  using Microsoft.Exchange.WebServices.Data;
  
  namespace TestEmail
  {
      class Program
      {
          static void Main(string[] args)
          {
              ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
              service.UseDefaultCredentials = true;
              //service.Credentials = new WebCredentials("user1@contoso.com", "password");
  
              service.TraceEnabled = true;
              service.TraceFlags = TraceFlags.All;
  
              service.AutodiscoverUrl("xxx@yyy.com", RedirectionUrlValidationCallback);
  
              EmailMessage email = new EmailMessage(service);
  
              email.ToRecipients.Add("xxx@yyy.com");
  
              email.Subject = "Test mail";
              email.Body = new MessageBody("Sending the test email");
  
              email.Send();
          }
  
          private static bool RedirectionUrlValidationCallback(string redirectionUrl)
          {
              // The default for the validation callback is to reject the URL.
              bool result = false;
  
              Uri redirectionUri = new Uri(redirectionUrl);
  
              // Validate the contents of the redirection URL. In this simple validation
              // callback, the redirection URL is considered valid if it is using HTTPS
              // to encrypt the authentication credentials. 
              if (redirectionUri.Scheme == "https")
              {
                  result = true;
              }
              return result;
          }
      }
    }
  }
  </code></pre>
  
  <p>But the workplace security settings disallow exposing autodiscovery endpoints, and I was informed that this setting can't be changed. </p>
  
  <p>Is there any other way for me to connect to the Exchange server, without using AutoDiscover?</p>
  
  <p>This is a follow up to my previous question <a href="https://stackoverflow.com/questions/43649299/ssl-tls-error-when-connecting-to-exchange-from-c-sharp">SSL/TLS error when connecting to Exchange from C#</a></p>