using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Net; using System.Net.Mail; using System.Text; public static void SendMail(string from, string to, string subject, string body) { MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress(from); mailMessage.To.Add(to); mailMessage.Subject = subject; mailMessage.IsBodyHtml = true; mailMessage.BodyEncoding = Encoding.UTF8; mailMessage.Body = body; mailMessage.Priority = MailPriority.Normal; // Smtp configuration for localhost / gmail SmtpClient client = new SmtpClient(); client.Credentials = new NetworkCredential("[DELETED]@gmail.com", "mukeshpa"); // enter your user name and password for gmail client.Port = 587; //use 465 or 587 ports for gmail //use 25 client.Host = "smtp.gmail.com";// for gmail //use "127.0.0.1"; client.EnableSsl = false; // true for gmail MailMessage message = mailMessage; try { client.Send(message); Show("sending mail........"); } catch (Exception ex) { Show("Sending fail.." + ex.ToString()); } } protected void Button1_Click(object sender, EventArgs e) { SendMail(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text); }
[edit]Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know - OriginalGriff[/edit]
client.EnableSsl = false; // true for gmail
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)