Hi All,
I need to send email from a C# application from localhost. I was successful in sending email using gmail SMPT port and host. But i need send email from local host SMPT virtual server. I followed the steps explained in http://forums.asp.net/t/268037.aspx and http://weblogs.asp.net/steveschofield/archive/2007/08/15/send-email-from-your-local-machine.aspx but the mail was not sending from my application. Also when i execute the command telnet mail.contoso.com 25 in commad promt. It shows "Connecting To mail.contoso.com...Could not open connection to the host, on port
25: Connect failed". Please help me to solve this.
Thanks

You should have to enabled - "Internet Mail Server (SMTP)" of firewall.

use this code for "localhost"

using System.Web.Mail;
.
.
.
	MailMessage xMailMessage = new MailMessage();
	xMailMessage.From = "My Test System <test@test.com>";
	xMailMessage.To = "vatoovatoo@mousavi.net";
	xMailMessage.Subject = "This is a test";
	xMailMessage.BodyFormat = MailFormat.Html;
	xMailMessage.Body = "<html><head><title>Test emial</title></head><br /><br /><hr>JUST A TEST<hr><br /><br /></body></html>";

	SmtpMail.SmtpServer = "localhost";
	SmtpMail.Send(xMailMessage);	
.
.
.

have a look at the attached.

Hi


MailMessage obj = new MailMessage();

obj.From = "abc@abc.com";
string Email = EmailId.ToString();

obj.To = Email;
obj.Subject = "Forgot SnapID";
obj.Body = flag.ToString();
obj.BodyFormat = MailFormat.Html;

SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.SmtpServer = "Localhost";
SmtpMail.Send(obj);

thanks

Shobhitzone

Hi All,
I need to send email from a C# application from localhost. I was successful in sending email using gmail SMPT port and host. But i need send email from local host SMPT virtual server. I followed the steps explained in http://forums.asp.net/t/268037.aspx and http://weblogs.asp.net/steveschofield/archive/2007/08/15/send-email-from-your-local-machine.aspx but the mail was not sending from my application. Also when i execute the command telnet mail.contoso.com 25 in commad promt. It shows "Connecting To mail.contoso.com...Could not open connection to the host, on port
25: Connect failed". Please help me to solve this.
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.