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.
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: “The requested security protocol is not supported”
We are using Using dotnet 4.5 and the code below is my test 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);
}
}
Any help to get this working would be much appreciated,
Thanks,
John