slow system.net.mail mailmessage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JoshP

    #1

    slow system.net.mail mailmessage

    Hi all, I am using an asp.net page to send e-mail to an internal exchange
    server. The code completes, but the mail doesn't get sent from webserver for
    at least a minute or more. Is there any reason why the e-mail is delayed?
    My code to mail is below:

    public void SendEmailToTech nician(string sTo, string sSubject, string
    sBody)
    {
    oMailMessage.Fr om = new
    MailAddress(Con figurationManag er.AppSettings["SMTPFromAddres s"].ToString());
    oMailMessage.To .Add(new MailAddress(sTo ));
    oMailMessage.Su bject = sSubject;
    oMailMessage.Bo dy = sBody + "<END MESSAGE>";
    oMailMessage.Is BodyHtml = false;
    oMailMessage.Pr iority = MailPriority.Hi gh;

    SmtpClient oClient = new
    SmtpClient(Conf igurationManage r.AppSettings["SMTPServer "].ToString());
    oClient.Deliver yMethod = SmtpDeliveryMet hod.Network;


    try
    {
    oClient.Send(oM ailMessage);
    }
    catch (Exception ex)
    {
    oGlobal.Redirec t("Error.aspx?E rror=" + ex.Message.ToSt ring() +
    "&STACK=" + ex.StackTrace.T oString());
    }
    }
  • Vadym Stetsyak

    #2
    Re: slow system.net.mail mailmessage

    Hello, JoshP!

    Your code only sends email to the smtp server. This server then delivers the mail to the specified destination address.

    So, I'd recommend you to check the smtp server, why does it takes it so long to deliver mail.

    If you have access to the smtp server, you can check its log and verify when mails was received and sent

    --
    Regards, Vadym Stetsyak
    www: http://vadmyst.blogspot.com

    Comment

    • JoshP

      #3
      Re: slow system.net.mail mailmessage

      Thanks for the reply Vadym. Interestingly enough, the webserver has Symantec
      Antivirus installed and when mail is sent you can see Symantec scanning the
      mail. However, Symantec on the webserver doesn't even see the message being
      sent for at least 45 seconds after the mail code is run. Any ideas? I have
      tried disabling Symantec to see if I get any speed increases--no luck.

      Thanks,
      Josh

      "Vadym Stetsyak" wrote:
      [color=blue]
      > Hello, JoshP!
      >
      > Your code only sends email to the smtp server. This server then delivers the mail to the specified destination address.
      >
      > So, I'd recommend you to check the smtp server, why does it takes it so long to deliver mail.
      >
      > If you have access to the smtp server, you can check its log and verify when mails was received and sent
      >
      > --
      > Regards, Vadym Stetsyak
      > www: http://vadmyst.blogspot[/color]

      Comment

      • Vadym Stetsyak

        #4
        Re: slow system.net.mail mailmessage

        Hello, JoshP!

        You mean that Symantec is on the sender and on the smtp server?
        You can try to see what is going on in the network level, using network sniffing tools ( Network monitor or Ethereal )

        --
        Regards, Vadym Stetsyak
        www: http://vadmyst.blogspot.com

        Comment

        • JoshP

          #5
          Re: slow system.net.mail mailmessage

          Hi Vadym, I ran a network trace using Ethereal. The SMTP converstation with
          the mail server begins immediately. However, after a brief millisecond, the
          converstation stops at 250 2.0.0 Resetting. It waits about 25-30 seconds
          then begins transmitting the data. I.e.:

          Response: 250 2. 0.0 Resetting
          Mail From:<email@dom an.com>
          250 2.1.0 email@domain.co m. . . Sender OK
          etc... etc... etc... until email is sent.

          Wonder what the delay is caused by at the "Resetting" point in the
          converstation?

          "Vadym Stetsyak" wrote:
          [color=blue]
          > Hello, JoshP!
          >
          > You mean that Symantec is on the sender and on the smtp server?
          > You can try to see what is going on in the network level, using network sniffing tools ( Network monitor or Ethereal )
          >
          > --
          > Regards, Vadym Stetsyak
          > www: http://vadmyst.blogspot[/color]

          Comment

          • Vadym Stetsyak

            #6
            Re: slow system.net.mail mailmessage

            Hello, JoshP!

            J> Response: 250 2. 0.0 Resetting
            J> Mail From:<email@dom an.com>
            J> 250 2.1.0 email@domain.co m. . . Sender OK
            J> etc... etc... etc... until email is sent.

            J> Wonder what the delay is caused by at the "Resetting" point in the
            J> converstation?

            No, resetting has nothing to do here.
            You mean that it looks like this

            J> Response: 250 2. 0.0 Resetting
            Here goest the delay (45 sec ) and then everything runs smoothly?
            J> Mail From:<email@dom an.com>
            J> 250 2.1.0 email@domain.co m. . . Sender OK
            J> etc... etc... etc... until email is sent.

            If the upper is true, then it is the problem on the sender side.

            Did you disable virus checking completely? ( in the low level untivirus device driver may still analyze data but won't prompt about it )

            --
            Regards, Vadym Stetsyak
            www: http://vadmyst.blogspot.com

            Comment

            • Ignacio Machin \( .NET/ C# MVP \)

              #7
              Re: slow system.net.mail mailmessage

              Hi,

              In addition I would suggest you to send the email from a Thread , this will
              allow that the user get a response page fast while the email is processed in
              the server.


              --
              Ignacio Machin,
              ignacio.machin AT dot.state.fl.us
              Florida Department Of Transportation

              "Vadym Stetsyak" <vadym_s@ukr.ne t> wrote in message
              news:uEHnww7OGH A.740@TK2MSFTNG P12.phx.gbl...[color=blue]
              > Hello, JoshP!
              >
              > J> Response: 250 2. 0.0 Resetting
              > J> Mail From:<email@dom an.com>
              > J> 250 2.1.0 email@domain.co m. . . Sender OK
              > J> etc... etc... etc... until email is sent.
              >
              > J> Wonder what the delay is caused by at the "Resetting" point in the
              > J> converstation?
              >
              > No, resetting has nothing to do here.
              > You mean that it looks like this
              >
              > J> Response: 250 2. 0.0 Resetting
              > Here goest the delay (45 sec ) and then everything runs smoothly?
              > J> Mail From:<email@dom an.com>
              > J> 250 2.1.0 email@domain.co m. . . Sender OK
              > J> etc... etc... etc... until email is sent.
              >
              > If the upper is true, then it is the problem on the sender side.
              >
              > Did you disable virus checking completely? ( in the low level untivirus
              > device driver may still analyze data but won't prompt about it )
              >
              > --
              > Regards, Vadym Stetsyak
              > www: http://vadmyst.blogspot.com[/color]


              Comment

              • JoshP

                #8
                Re: slow system.net.mail mailmessage

                Hi Vadym, you were right!! The problem was from the sender-side. When I
                disabled Symantec Corporate Antivirus, I did it from the icon in the system
                tray. Once I disabled the service in the services snap-in the mail would
                send right away. I still don't understand how or why Symantec Antivirus
                would cause a 58 second delay in sending e-mail.

                "Vadym Stetsyak" wrote:
                [color=blue]
                > Hello, JoshP!
                >
                > J> Response: 250 2. 0.0 Resetting
                > J> Mail From:<email@dom an.com>
                > J> 250 2.1.0 email@domain.co m. . . Sender OK
                > J> etc... etc... etc... until email is sent.
                >
                > J> Wonder what the delay is caused by at the "Resetting" point in the
                > J> converstation?
                >
                > No, resetting has nothing to do here.
                > You mean that it looks like this
                >
                > J> Response: 250 2. 0.0 Resetting
                > Here goest the delay (45 sec ) and then everything runs smoothly?
                > J> Mail From:<email@dom an.com>
                > J> 250 2.1.0 email@domain.co m. . . Sender OK
                > J> etc... etc... etc... until email is sent.
                >
                > If the upper is true, then it is the problem on the sender side.
                >
                > Did you disable virus checking completely? ( in the low level untivirus device driver may still analyze data but won't prompt about it )
                >
                > --
                > Regards, Vadym Stetsyak
                > www: http://vadmyst.blogspot[/color]

                Comment

                • Vadym Stetsyak

                  #9
                  Re: slow system.net.mail mailmessage

                  IMHO it depends on the mail being send, if it has binary attachments.
                  OR there is a bug in the Symantec scanner...

                  What are you sending in your mails?

                  --
                  Regards, Vadym Stetsyak
                  www: http://vadmyst.blogspot.com

                  Comment

                  • JoshP

                    #10
                    Re: slow system.net.mail mailmessage

                    I am sending plain text only. Also, I am using the latest available
                    Syamantec Antivirus Corporate Edition. I think I will give Symantec a call
                    and find out how the mail scanner code works. Thanks for your time and
                    helping me solve or at least identify the problem. Thanks Again....

                    "Vadym Stetsyak" wrote:
                    [color=blue]
                    > IMHO it depends on the mail being send, if it has binary attachments.
                    > OR there is a bug in the Symantec scanner...
                    >
                    > What are you sending in your mails?
                    >
                    > --
                    > Regards, Vadym Stetsyak
                    > www: http://vadmyst.blogspot[/color]

                    Comment

                    Working...