public void SendHTMLMail() { MailMessage Msg = new MailMessage(); MailAddress fromMail = new MailAddress("xxxxx@gmail.com"); // Sender e-mail address. Msg.From = fromMail; // Recipient e-mail address. Msg.To.Add(new MailAddress("xxxxxxxx@gmail.com")); // Subject of e-mail Msg.Subject = "Send Gridivew in EMail"; Msg.Body += "Please check below data <br /><br />"; Msg.Body += GetGridviewData(gvUserInfo); Msg.IsBodyHtml = true; string sSmtpServer = ""; sSmtpServer = "587"; SmtpClient a = new SmtpClient(); a.Host = sSmtpServer; a.EnableSsl = true; a.Send(Msg); }
Quote:System.Net.Mail; using System.Net; var fromAddress = new MailAddress("from@gmail.com", "From Name"); var toAddress = new MailAddress("to@yahoo.com", "To Name"); const string fromPassword = "password"; const string subject = "test"; const string body = "Hey now!!"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential(fromAddress.Address, fromPassword), Timeout = 20000 }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)