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("test@dotnet.itags.org.test.com);
msg.To.Add(new MailAddress("test@dotnet.itags.org.test.com"));
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.AppSetti ngs["smtpaddress"];
client.Send(msg);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.AppSetti ngs["smtpaddress"];
Line 50:
Line 51: client.Send(msg);
Line 52:
Line 53: // send user to confirmation page
-------
"Sammy" wrote:
Quote:
Originally Posted by
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("test@.test.com);
msg.To.Add(new MailAddress("test@.test.com"));
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.AppSetti ngs["smtpaddress"];
client.Send(msg);
0 comments:
Post a Comment