R
Ramon
Hi,
I'm trying to send an HTML e-mail (using ASP.NET 3.5) by initialising a
SmtpClient object and calling the method SendAsync(). For some reason,
it throws System.Net.Mail.SmtpException -- "Failure sending mail.".
Strangely enough, e-mails sent using Send() method (i.e. synchronous)
were all delivery successfully!
Here is my code:
[MethodImpl(MethodImplOptions.Synchronized)]
public static void SendHtmlEmail(
String emailAddress,
String name,
String subject,
String message,
SendCompletedEventHandler emailEventHandler)
{
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(new MailAddress(emailAddress));
mailMessage.Subject = subject;
mailMessage.IsBodyHtml = true;
mailMessage.Body = message;
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.SendCompleted += emailEventHandler;
smtpClient.SendAsync(mailMessage, "e-mail");
}
Can somebody figure out what am I doing wrong?
Thanks.
I'm trying to send an HTML e-mail (using ASP.NET 3.5) by initialising a
SmtpClient object and calling the method SendAsync(). For some reason,
it throws System.Net.Mail.SmtpException -- "Failure sending mail.".
Strangely enough, e-mails sent using Send() method (i.e. synchronous)
were all delivery successfully!
Here is my code:
[MethodImpl(MethodImplOptions.Synchronized)]
public static void SendHtmlEmail(
String emailAddress,
String name,
String subject,
String message,
SendCompletedEventHandler emailEventHandler)
{
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(new MailAddress(emailAddress));
mailMessage.Subject = subject;
mailMessage.IsBodyHtml = true;
mailMessage.Body = message;
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.SendCompleted += emailEventHandler;
smtpClient.SendAsync(mailMessage, "e-mail");
}
Can somebody figure out what am I doing wrong?
Thanks.