473,396 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SmtpClient Email Error

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("te**@test.com);
msg.To.Add(new MailAddress("te**@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);
Nov 1 '06 #1
1 1687
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:
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("te**@test.com);
msg.To.Add(new MailAddress("te**@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);
Nov 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jay | last post by:
The code below is a recommended way to send email with c# from my aspx page: MailMessage mail = new MailMessage(); mail.From = new MailAddress("development@ziptax.com"); mail.To.Add(new...
11
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running...
10
by: David Thole | last post by:
Hey all, I'm still very new at all this, but am going through the ASP.net 2.0 unleashed book, first chapter and trying to program my own little form emailer for fun. I tried following the code...
0
by: howardr101 | last post by:
Hi, Have hunted around on the groups and can't find anything, hence. I've tried this against 2 mail servers (mailtraq and hmailserver) and it occus with both. The problems seems to be that...
2
by: clevrmnkey | last post by:
I've had nothing but trouble from the System.Net.Mail objects, but I finally need to make them work, and I can't for the life of me see what I'm doing wrong. I pared back my mail transaction to...
2
by: Robson Siqueira | last post by:
Folks, I've been experiencing a weird problem. I have a web service which sends an email after its processing. The email always has an PDF attachment on it. The PDF size vary overtime. The...
1
by: les | last post by:
I'm getting this error "BC30456: 'IsBodyHtml' is not a member of 'System.Net.Mail.SmtpClient'" when trying to submit a form and send email. If I remove the line "MailObj.IsBodyHtml = True" the...
6
by: =?Utf-8?B?VG9yc3Rlbg==?= | last post by:
Hi, I have a problem sending mails with the SmtpClient class. It's strange - after I boot the pc and start the program I can send mails many times. After I close the program and start it again...
2
by: btcoder | last post by:
Hi, my jsp page uses sun.net.smtp.SmtpClient to send email. It worked fine until the hosted location was moved to another server. Now it generates the sun.net.smtp.SmtpProtocolException and the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.