How to cancel sending emails synchronously?

I create sending emails synchronously.



SmtpClient client = new SmtpClient(…);

MailMessage msg = new MailMessage();



msg.Attachments.Add("…");

client.Send(msg);



Can I cancel sending emails synchronously?

Thanks.

Hi,

Thanks for considering Aspose.

Emails that are being sent synchronously, cannot be canceled. You need to send asynchronously using SmtpClient.SendAsync() method. If there are large number of emails, the best way is to use SmtpClientBulkSendAgent class.

Please see the attached demo that uses SmtpClientBulkAgent class to send multiple emails. It also shows the progress (Messages sent: 1 of n). If you stop the process, you can also get the recipients, to whom email could not be sent.

Hi.

Thank you.