We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

OperationCancelledException after Upgrading Aspose.Email to Version 21.5


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?

Kind regards,

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!

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.

Thanks for the response! Here is the stack trace:

    #=zu$FnsJBaomaGGgGs$h2dPwP9seOK.#=zOg87x8Hg02qi(int, #=zxkLbMQAqxHJE1UZtXp_OHaP4IuVeQVgNfA==)
    #=zirNI$9FSMqK4aNokyUKKMxcZXW1c.#=zeJhlcSg=(System.AsyncCallback, object)
    Aspose.Email.Clients.Smtp.SmtpClient.#=zGtwG9Uc=(Aspose.Email.Clients.IConnection, System.Collections.Generic.IEnumerable<Aspose.Email.MailMessage>, System.EventHandler<Aspose.Email.Clients.Smtp.MailMessageEventArgs>, System.AsyncCallback, object)
    Aspose.Email.Clients.Smtp.SmtpClient.Send(Aspose.Email.Clients.IConnection, System.Collections.Generic.IEnumerable<Aspose.Email.MailMessage>)
    AsposeEmailTest.Program.Main(string[]) in Program.cs

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();

            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"
            Console.WriteLine("Message sent");


The same code successfully sends the email using version 21.4 and prior versions.

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.

The issues you have found earlier (filed as EMAILNET-40265) have been fixed in this update.