ASP 2.0 Net.Mail.SmtpClient Delay

Discussion in 'ASP .Net' started by mazdotnet, May 9, 2006.

  1. mazdotnet

    mazdotnet Guest

    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 = "";
    MyMail.Subject = "Test";
    MyMail.Body = body;
    MyMail.BodyFormat = System.Web.Mail.MailFormat.Html;
    System.Web.Mail.SmtpMail.SmtpServer = SmtpServer;
    MyMail.To = ""
    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
     
    mazdotnet, May 9, 2006
    #1
    1. Advertisements

  2. mazdotnet

    MSDN Guest

    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

    "mazdotnet" <> wrote in message
    news:...
    > 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 = "";
    > MyMail.Subject = "Test";
    > MyMail.Body = body;
    > MyMail.BodyFormat = System.Web.Mail.MailFormat.Html;
    > System.Web.Mail.SmtpMail.SmtpServer = SmtpServer;
    > MyMail.To = ""
    > 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
    >
     
    MSDN, May 9, 2006
    #2
    1. Advertisements

  3. mazdotnet

    sloan Guest

    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


    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)



    \

    "mazdotnet" <> wrote in message
    news:...
    > 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 = "";
    > MyMail.Subject = "Test";
    > MyMail.Body = body;
    > MyMail.BodyFormat = System.Web.Mail.MailFormat.Html;
    > System.Web.Mail.SmtpMail.SmtpServer = SmtpServer;
    > MyMail.To = ""
    > 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
    >
     
    sloan, May 9, 2006
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SG90UVE=?=
    Replies:
    0
    Views:
    3,445
    =?Utf-8?B?SG90UVE=?=
    May 6, 2005
  2. Replies:
    3
    Views:
    1,249
  3. =?Utf-8?B?QnJpYW4gTG9ycmFpbmU=?=

    Mail.SmtpClient sending duplicates

    =?Utf-8?B?QnJpYW4gTG9ycmFpbmU=?=, Jun 13, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    1,353
    vMike
    Jun 14, 2006
  4. refv8
    Replies:
    2
    Views:
    27,391
    ittower
    Oct 13, 2006
  5. Guest

    System.Net.Mail.SmtpClient

    Guest, Sep 15, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    15,278
    Steven Cheng[MSFT]
    Sep 18, 2006
Loading...

Share This Page