using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Mail; using System.Web; namespace HeenaTravel.Models { public class EmailSender { public bool SendEmail(string SendTo, string Body, string Subject) { SmtpClient smtp = new SmtpClient(); MailMessage msg = new MailMessage(); MailAddress from = new MailAddress("kajalhansapur@gmail.com"); MailAddress to = new MailAddress(SendTo); // network cridentials setting starts here NetworkCredential nc = new NetworkCredential("kajalhansapur@gmail.com", "lbsnaa9119system"); smtp.EnableSsl = true; smtp.UseDefaultCredentials = false; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = nc; //network credential setting end here //MailMessage setting start here msg.Sender = from; msg.Subject = Subject; msg.To.Add(to); msg.From = from; msg.Body = Body; smtp.Send(msg); return true; } } }