slow system.net.mail mailmessage

G

Guest

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 SendEmailToTechnician(string sTo, string sSubject, string
sBody)
{
oMailMessage.From = new
MailAddress(ConfigurationManager.AppSettings["SMTPFromAddress"].ToString());
oMailMessage.To.Add(new MailAddress(sTo));
oMailMessage.Subject = sSubject;
oMailMessage.Body = sBody + "<END MESSAGE>";
oMailMessage.IsBodyHtml = false;
oMailMessage.Priority = MailPriority.High;

SmtpClient oClient = new
SmtpClient(ConfigurationManager.AppSettings["SMTPServer"].ToString());
oClient.DeliveryMethod = SmtpDeliveryMethod.Network;


try
{
oClient.Send(oMailMessage);
}
catch (Exception ex)
{
oGlobal.Redirect("Error.aspx?Error=" + ex.Message.ToString() +
"&STACK=" + ex.StackTrace.ToString());
}
}
 
V

Vadym Stetsyak

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
 
G

Guest

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
 
V

Vadym Stetsyak

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
 
G

Guest

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 protected]>
250 2.1.0 (e-mail address removed). . . Sender OK
etc... etc... etc... until email is sent.

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

Vadym Stetsyak

Hello, JoshP!

J> Response: 250 2. 0.0 Resetting
J> Mail From:<[email protected]>
J> 250 2.1.0 (e-mail address removed). . . 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 protected]>
J> 250 2.1.0 (e-mail address removed). . . 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
 
I

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

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.
 
G

Guest

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.
 
G

Guest

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....
 

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

Similar Threads


Top