Thursday, November 20, 2008

Let users send you email throw GMAIL in your site

You can create a contact us form for example and allow visitors on your site to fill some details and get that data into your gmail account.

using System.Net;
using System.Net.Mail;

protected void SendMail()

MailMessage email = new MailMessage();

MailAddress adressToSend = new MailAddress("your gmail adress");

email.From = new MailAddress("user email adress");
email.Subject = "email subject";
email.Body = " email body ";

SmtpClient client = new SmtpClient("", 587);
client.EnableSsl = true;
NetworkCredential myCreds = new NetworkCredential("your gmail username", "your gmail password");
client.Credentials = myCreds;

catch {}


Hope that was helpful


No comments: