ASP 2.0 Net.Mail.SmtpClient Delay

M

mazdotnet

Hi everyone,

I'm coverting some of our code here from the old way of sending mail in
..NET 1.1 to the new .NET 2.0. However, everytime I switch the code to
the new method there is a delay of 1-2 minutes before an email is sent
(this is on my local computer pointing 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);

Thank you
Maz
 
M

MSDN

I have used Net.Mail through my local smtp to my internal email and that
was immediate
No delays at all. Did not try sending to Hotmail or Gmail

SA
 
S

sloan

http://spaces.msn.com/sholliday/ 2/8/2006


Try sending your email to your gmail account .. THRU gmail smtp server.

I think your issue is hotmail and gmail. You probably need to test it
against a "normal" email address like
(e-mail address removed)

Check my blog, if you download the project, you can see how to send thru the
gmail smtp server .. in 1.1 and 2.0 (slightly different settings)



\
 

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

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top