John Skinner

John Skinner

  • NA
  • 7
  • 3.3k

Attempting to use Exchange Web Services

Feb 4 2016 6:59 PM

Hi, 

I am attempting to write a test application in c# that uses Exchange Web Services over TLS1.2 to connect the Exchange Server 2010 and send an email.

I have used the example downloaded from https://code.msdn.microsoft.com/Send-Email-with-Exchange-50189e57 as a starting point with minor changes to suit our Exchange configuration.

Our Exchange server is configured to use TLS 1.2

If I run the program from inside our domain it is successful but if I run it from outside then I get the following message:

Using dotnet 4.5

“The requested security protocol is not supported”

    1. private void sendButton_Click(object sender, RoutedEventArgs e)  
    2.  {  
    3.      try  
    4.      {  
    5.          ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);  
    6.          service.Url = new Uri(ExchangeServerURI);  
    7.          ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;  
    8.          service.Credentials = new WebCredentials(MailUserName, MailPassword);  
    9.   
    10.          EmailMessage message = new EmailMessage(service);  
    11.          message.Subject = subjectTextbox.Text;  
    12.          message.Body = bodyTextbox.Text;  
    13.          message.ToRecipients.Add(recipientTextbox.Text);  
    14.          message.Save();  
    15.   
    16.          message.SendAndSaveCopy();  
    17.   
    18.          System.Windows.MessageBox.Show("Message sent!");  
    19.      }  
    20.      catch(Exception ex)  
    21.      {  
    22.          MessageBox.Show(ex.Message);  
    23.      }  
    24.  }  
     

Any help to get this working would be much appreciated,

Thanks,

John


Answers (1)