Wrox Programmer Forums
|
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
 
Old July 26th, 2011, 01:36 PM
Authorized User
 
Join Date: Mar 2010
Posts: 27
Thanks: 2
Thanked 1 Time in 1 Post
Default

ok Mr.Imar,
This is my code:
Quote:
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 = "Localhost";
System.Web.Mail.SmtpMail.Send(message);

}
My server Name is : Localhost.

The error occured is
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 = "Localhost";
Line 34: System.Web.Mail.SmtpMail.Send(message);
 
Old July 26th, 2011, 01:40 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, I know all that, as you said the same in your previous messages ;-)
However, in order to solve this, you need to figure out answers to my questions:

Quote:
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?
In order for this to work, you need an SMTP server you can communicate with. This *could* be localhost, but for that to work, you need to have an SMTP server installed locally. This doesn't get installed by default, so unless you installed one explicitly, there's a fair chance you don't have one. Google for "install SMTP server windows" for more details.

As an alternative to a localhost SMTP server, you could use the one you already use for e-mail on your desktop. This host is typically supplied by your ISP or network administrator.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.