c# exchange web services over tls1.2
<p>I have spent the last few weeks searching the Internet for a solution to this issue without any luck so I am turning to the community here for help.</p>

<p>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. </p>

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

<p>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: 
“The requested security protocol is not supported”</p>

<p>We are using Using dotnet 4.5 and the code below is my test code.</p>

<pre><code>private void sendButton_Click(object sender, RoutedEventArgs e)
    {
        try
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
            service.Url = new Uri(ExchangeServerURI);
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            service.Credentials = new WebCredentials(MailUserName, MailPassword, "api");

            EmailMessage message = new EmailMessage(service);
            message.Subject = subjectTextbox.Text;
            message.Body = bodyTextbox.Text;
            message.ToRecipients.Add(recipientTextbox.Text);
            message.Save();

            message.SendAndSaveCopy();

            System.Windows.MessageBox.Show("Message sent!");
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
</code></pre>

<p>Any help to get this working would be much appreciated,</p>

<p>Thanks,</p>

<p>John</p>