System.Net.Mail.SmtpClient is slower

M

maflatoun

Hi everyone,

I'm coverting some of our code here from the old way of send email in
..net 1.1 to the new .net 2.0. However, everyone I switch the code the
new method there is a delay of 1-2 minutes before an email is sent
(this is on my local computer point to my local smtp -> localhost).
Anyone knows what the problem could be? BTW my computer in located
behind a firewall and I'm sending test emails to my gmail account and
hotmail account. It seems like the new way always takes around 2
minutes to send the email.


============ Old way ==========
System.Web.Mail.MailMessage MyMail= new
System.Web.Mail.MailMessage();
MyMail.From = "(e-mail address removed)";
MyMail.Subject = "Test";
MyMail.Body = body;
MyMail.BodyFormat = System.Web.Mail.MailFormat.Html;
System.Web.Mail.SmtpMail.SmtpServer = SmtpServer;
MyMail.To = "(e-mail address removed)"
System.Web.Mail.SmtpMail.Send(MyMail);

============ New way ==========
System.Net.Mail.SmtpClient mail = new System.Net.Mail.SmtpClient();
mail.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
mail.UseDefaultCredentials = false;
mail.Host = SMTPServer;
string subject = "Test";
string body;
body = DateTime.Now + "\r\n";
body += comment;
MailAddress sender = new MailAddress(from);
MailMessage mailMessage = new MailMessage();
string[] recipients = to.Split(';');

mailMessage.From = sender;

// Add recipients separated by ;
foreach (string recipient in recipients)
{
mailMessage.To.Add(recipient);
}

mailMessage.Body = body;
mailMessage.Subject = subject;

mail.Send(mailMessage);
 
G

Guest

think this might be down to your virus checker! - ours holds email for about
2 mins when sent with the new way, but allowes them to go through instantly
with the old one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top