To send mail use the following code:
Firstly add the following namespace:
using System.Net.Mail;
Then write the following code:
//Create a Client
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.EnableSsl = true;
client.Port = 587;
client.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "password");
MailMessage mail = new MailMessage("From@gmail.com", "To@gmail.com", "Subject", "Body");
client.Send(mail);
No comments:
Post a Comment