SMTP Mail


using System;
using System.Web.Mail;

namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
	MailMessage Message = new MailMessage();
	Message.To = "to_address@domain.com";
	Message.From = "from_address@domain.com";
	Message.Subject = "test1";
	Message.Body = "test1";

	try
	{
		Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
		Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "muneebsa");
		Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "you03ahm");
		Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2);
		Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.sbcglobal.yahoo.com");
		Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout", 10);
		Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
		Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", false); 

		SmtpMail.SmtpServer = "smtp.mydomain.com";
		SmtpMail.Send(Message);
	}
	catch(System.Web.HttpException ehttp)
	{
		Console.WriteLine("{0}", ehttp.Message);
		Console.WriteLine("Here is the full error message output");
		Console.Write("{0}", ehttp.ToString());
	}

}
}
}


You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

AddThis Social Bookmark Button

Similar Posts

Comments are closed.