Showing posts with label gmail. Show all posts
Showing posts with label gmail. Show all posts

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.To.Add(adressToSend);
email.From = new MailAddress("user email adress");
email.Subject = "email subject";
email.Body = " email body ";

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


try
{
client.Send(email);
}
catch {}

}


Hope that was helpful

Tomer