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”
- 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);
-
- 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
I