SmtpClient Email Error

G

Guest

I am using the following code on a company that hosts our web site. I have
noticed lately that their mail server/smtp is unavailable several times a
minute for a second or two. This is causing my script to fail when it calls
the client.Send(msg);

Will adding "client.Timeout = 1000000;" help my problem if the server can't
be reached or does the timeout assume the server can be reached but waits for
it to become less busy?

// create email
MailMessage msg = new MailMessage();
msg.From = new MailAddress("(e-mail address removed));
msg.To.Add(new MailAddress("(e-mail address removed)"));
msg.Subject = "Test Message";
string bod = "<html><head><body><b>Message:</b><br>blah test</body></html>";
msg.Body = bod;
msg.IsBodyHtml = true;

// send email
SmtpClient client = new SmtpClient();
client.Host =
System.Configuration.ConfigurationManager.AppSettings["smtpaddress"];
client.Send(msg);
 
G

Guest

Also, the exact error I am getting is:
--------------------
Service not available, closing transmission channel. The server response
was: Command timeout, closing transmission channel
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: Service not available,
closing transmission channel. The server response was: Command timeout,
closing transmission channel

Source Error:


Line 49: client.Host =
System.Configuration.ConfigurationManager.AppSettings["smtpaddress"];
Line 50:
Line 51: client.Send(msg);
Line 52:
Line 53: // send user to confirmation page
 

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


Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top