public void SendMail(string ToMail, string subject, string Message) { // Gmail Address from where you send the mail string fromAddress = "[email protected]"; // any address where the email will be sending //string toAddress = ToMail; //Password of your gmail address const string fromPassword = "********"; // Passing the values and make a email formate to display //string subject = subject; string body = "\n\n"+Message; // smtp settings var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential(fromAddress, fromPassword); smtp.Timeout = 20000; } // Passing values to smtp object smtp.Send(fromAddress, ToMail, subject, body); }
Help me in solving this...