We are upgrading our software from version 18.6 to version 21.5 and are now noticing an OperationCancelledException getting thrown when attempting to send email. Debugging this, it appears that the SmtpClient.SecurityOptions property is not behaving the same between versions. Specifically, the SecurityOptions.Auto value does not appear to work anymore against an Office365 smtp server. I’ve tried using SecurityOptions.SSLAuto and it also throws the OperationCancellledException when sending mail. Setting the value to SecurityOptions.SSLExplicit eliminates the exception and the mail is sent.
Is this a known issue with SecurityOptions.Auto? Should SecurityOptions.SSLAuto work in this scenario?
Additional testing show that this regression happened in build 21.5.0, as 21.4.0 and previous versions all work with SecurityOptions.Auto set. Hope this helps!
@kellyh,
Welcome to our community! Thank you for the issue description and additional information. To investigate this case on our side, please share and specify the following:
code example that works with version 18.6 and 21.4 and throws the error with version 21.5
version of OS on which the code example throws the error
stack trace of the error
It would be great if you could provide test credentials for us to investigate this case on your side.
The code that I’m testing with is shown below, however the account credentials have been removed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Email;
using Aspose.Email.Clients.Smtp;
namespace AsposeEmailTest
{
class Program
{
static void Main(string[] args)
{
var license = new Aspose.Email.License();
license.SetLicense("Aspose.Email.lic");
var smtpClient = new SmtpClient("smtp.office365.com", 587, "mail-email@here", "<password here>")
{
SecurityOptions = Aspose.Email.Clients.SecurityOptions.Auto
};
var message = new MailMessage("mail-email@here", "testaccount@mydomain.com")
{
Subject = "Test message",
Body = "This is a test of Aspose email"
};
smtpClient.Send(message);
Console.WriteLine("Message sent");
}
}
}
The same code successfully sends the email using version 21.4 and prior versions.
@kellyh,
Thank you for the additional information. I logged the issue with ID EMAILNET-40265 in our tracking system. Our development team will investigate this case. I will inform you of any progress.