Mail Sending
I want to create send mail option in my website. How to do its.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
sudharsan sPosted Jul 13, 2012, 6:20 AM
{
string Email = email.Text;
string MailSub = "Registration Information.";
string EventDescription = " Your Email" + Email + ",
";
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress("[email protected]");
mMailMessage.To.Add(new MailAddress(Email));
mMailMessage.Subject = "Password Information.";
mMailMessage.Body = EventDescription;
mMailMessage.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true; //ssl must be enabled for Gmail
//our Gmail account credentials
NetworkCredential credentials = new NetworkCredential("[email protected]", "password");
//add credentials to our smtp client
client.Credentials = credentials;
client.Send(mMailMessage);
Page.RegisterStartupScript("onclick", "");
}
HInt:
1. string Email = email.Text; this is the to address mail id. i am getting this from text box.
email.Text---> textbox id
2. gmail port 587 . your using other mail domain means use that port number.
this is only the mail sending function. you call this function inside of send mail button click event.