 |
| ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 26th, 2011, 11:31 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
|
|
send email
I have this code :
Code:
protected void Button1_Click(object sender, EventArgs e)
{
System.Web.Mail.MailMessage message = new System.Web.Mail.MailMessage();
message.From = "[email protected]";
message.To = "[email protected]";
message.Subject = "Send Email";
message.Body = "Massage Recived";
System.Web.Mail.SmtpMail.SmtpServer = "SMTP Server Address";
System.Web.Mail.SmtpMail.Send(message);
}
But this error occured:
Quote:
The transport failed to connect to the server.
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.Runtime.InteropServices.COMException: The transport failed to connect to the server.
Source Error:
Line 32: message.Body = "Massage Recived";
Line 33: System.Web.Mail.SmtpMail.SmtpServer = "SMTP Server Address";
Line 34: System.Web.Mail.SmtpMail.Send(message);
|
Help me please.
|
|

July 26th, 2011, 11:36 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Maybe your server requires SSL, a user name and password, or a specific port number? You can set a number of properties on an instance of the SmtpClient. Alternatively (and easier IMO), you can configure these settings in the <system.net> element in web.config.
Cheers,
Imar
|
|

July 26th, 2011, 11:45 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
|
|
ok,
But I have no idea about this subject.
could you tell me how I configure these settings in the <system.net> element in web.config
|
|

July 26th, 2011, 11:53 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Take a look here for an example: http://imar.spaanjaars.com/505/using...at-require-ssl
You'll need to ask your host / the admin of the SMTP server for server specific details.
Cheers,
Imar
|
|

July 26th, 2011, 12:16 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
|
|
I am working on ASP.NET server
so what's the user name and the password.
|
|

July 26th, 2011, 12:38 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What do you mean with "on ASP.NET server"? Can you elaborate?
Imar
|
|

July 26th, 2011, 12:51 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
|
|
I using localhost server.
|
|

July 26th, 2011, 01:07 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Also for outgoing mail? What did you enter for "SMTP Server Address" in your code?
Imar
|
|

July 26th, 2011, 01:15 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
|
|
I did like this
System.Web.Mail.SmtpMail.SmtpServer = "Localhost";
|
|

July 26th, 2011, 01:22 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
And do you have an SMTP server installed locally? Or is there another SMTP server (from your internet provider for example) that you can use?
If you have follow up questions, please try to explain your setup, settings and code in more detail, or this thread could get very long.... ;-)
Cheers,
Imar
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Need to send email |
garrettbrennan |
Visual C++ |
0 |
September 13th, 2007 12:24 PM |
| How to send email |
abiye49 |
Excel VBA |
1 |
January 10th, 2007 03:32 PM |
| Send by email |
tsimsha |
Classic ASP Databases |
1 |
October 1st, 2005 03:03 AM |
| Send email |
Danny_n |
BOOK: Excel 2003 VBA Programmer's Reference |
0 |
January 12th, 2005 08:32 AM |
| send email |
X-Ken |
VS.NET 2002/2003 |
8 |
July 2nd, 2004 06:13 AM |
|
 |