It happens occasionally that, sending mails using the method SendMessage(IMail email) of class Smtp, the execution flow never returns from it locking the entire application.
What could be the problem and how can it be solved or diagnosed so that the method returns at least an error through ISendMessageResult eventually after timeout expiration?
(in the code snippet i set the timeout for the Smtp object but it does not seem to work)
code snippet for sending email:
using (Smtp smtpClient = new Smtp())
// Timeout in secondi
TimeSpan sendTimout = new TimeSpan(0, 0, 30);
smtpClient.SendTimeout = sendTimout;
_server, _port) && messaggio.To.Count>0)
ISendMessageResult result = smtpClient.SendMessage(
_log.Info("Email sending result: " + result);
if (result.Status == SendMessageStatus.Success)
Executing the code, logging stops at the "ISendMessageResult result = smtpClient.SendMessage(messaggio);" statement, even though there is a log right at the next statement, and the mail is never sent.
After restarting the blocked application, the same mail was sent succesfully.