Sending Email through Gmail in ASP.NET page

21 04 2008

public static bool SendEmail(string siteEmail ,string requesterAddress, string link)
{
try
{
int port = 587;
string userName = “tahir.rauf1@gmail.com”;
string password = “Allahakbar”;

MailMessage mailMsg = new MailMessage();
SmtpClient mailObject = new SmtpClient(“smtp.gmail.com”,port);

mailMsg.From = new MailAddress(siteEmail, “FLVZ”);
mailMsg.To.Add(new MailAddress(requesterAddress));
mailMsg.IsBodyHtml = false;
mailMsg.Body = link;
mailMsg.Subject = “This is the Subject”;

mailObject.Credentials = new System.Net.NetworkCredential(userName, password);
mailObject.Send(mailMsg);
return true;
}
catch
{
return false;
}
}

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: