Free Support Forum - aspose.com

"Operation has been canceled" when sending SMTP mail

I use Aspose.Email to send mail using SMTP to communicate with our exchange 2016 server.
With Aspose.Email 19.12 everything worked fine, but when I upgraded to 20.12 it stopped working.
I also tried 21.1, same problem.

Edit 13:10: I know the exact versionnr of the version where it doesn’t work anymore. It’s 20.12. In 20.11 it’s working, in 20.12 not.

If I send an email, an error “Operation has been canceled” occurs. (OperationCanceledException)

Some details:

  • SMTP server is only accessible on premise
  • Connect to port 25
  • Login with username/password
  • SecurityOptions set to ‘Auto’.

Note: If I set SecurityOptions to ‘None’ I’ll get a different error: Authentication Failed.

Trace:

System.OperationCanceledException: Operation has been canceled
at #=zzukH64qg$tm92KBZitvQtVDGlotw.#=zpiK2ofQ=(IAsyncResult #=z4fp5qus=)
at #=zzukH64qg$tm92KBZitvQtVDGlotw.#=zgq$rb8U=()
at #=zVtEuSOHpzqzupz$AbByJd9OtqIL2Vb8UGljlmf4=.#=zJF_TWIE=(#=zyQ7xRVUnf1XuFJjGp6kU54zdiZNmN3Qp0w== #=zxE_VckI=)
at #=zEITzYyCDn78orbjcQ$NAtUZa1_60.#=z1chyIb0hj1FF(Int32 #=zHVE4QKE=, #=zyQ7xRVUnf1XuFJjGp6kU54zdiZNmN3Qp0w== #=zov9$WD8=)
at #=zzukH64qg$tm92KBZitvQtVDGlotw.#=zmVx0dNl2HehK()
at #=zzukH64qg$tm92KBZitvQtVDGlotw.#=zQN6cggQ=(AsyncCallback #=zwzsYyko=, Object #=z0CT2r0c=)
at Aspose.Email.Clients.Smtp.SmtpClient.BeginSend(IConnection connection, IEnumerable1 messages, EventHandler1 messageSentDelegate, AsyncCallback callback, Object state)
at Aspose.Email.Clients.Smtp.SmtpClient.Send(IConnection connection, IEnumerable`1 messages)
at Aspose.Email.Clients.Smtp.SmtpClient.Send(MailMessage message)

Can you please help?

@GerhardTM
Thank you for the issue description. Could you share a simple standalone project or code snippet for reproducing and investigating the problem, please? Also, we need the original email file sample.

@Andrey_Potapov
Here’s a very simple code snippet for sending mail. In 20.11 it’s working, in 20.12 it’s broken:

        MailMessage message = new MailMessage();

        // Set From field, To field and Plain text body
        message.From = "test@ekro.nl";
        message.To.Add("test@ekro.nl");
        message.Subject = "Test";
        message.Body = "Test";

        // Create an instance of the SmtpClient class
        SmtpClient client = new SmtpClient();

        // And Specify your mailing host server, Username, Password and Port
        client.Host = "mailserver";
        client.Port = 25;

        client.UseAuthentication = true;
        
        client.Username = @"username";
        client.Password = @"password";

        client.EnableLogger = true;
        client.LogFileName = @"c:\temp\smtp.log";

        client.SecurityOptions = SecurityOptions.Auto;

        try
        {
            //Client.Send will send this message
            client.Send(message);
            Console.WriteLine("Message sent!");
            Console.ReadLine();
        }
        catch (OperationCanceledException ex)
        {
            Trace.WriteLine(ex.ToString());
        }
        catch (Exception ex)
        {
            Trace.WriteLine(ex.ToString());
        }