try { string from = "xxx@gmail.com"; //Replace this with your own correct Gmail Address string to = "yyy@gmail.com"; //Replace this with the Email Address //to whom you want to send the mail System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); mail.To.Add(to); mail.From = new MailAddress(from, "One Ghost", System.Text.Encoding.UTF8); mail.Subject = "This is a test mail"; mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Body = "This is Email Body Text"; mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; mail.Priority = MailPriority.High; SmtpClient client = new SmtpClient("smtp.gmail.com", 587); //Add the Creddentials- use your own email id and password System.Net.NetworkCredential nt = new System.Net.NetworkCredential(from, "zzzzzz"); client.Port = 587; // Gmail works on this port client.EnableSsl = true; //Gmail works on Server Secured Layer client.UseDefaultCredentials = false; client.Credentials = nt; client.Send(mail); } catch(Exception ex) { Response.Write("Could not send the e-mail - error: " + ex.Message); } return View();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)