//Please follow the below steps to send the mail
/*Go to your Gmail==> Google Account ==> On the left sie click security
==>Enable ON for the "Allow less secure apps",that is present in the bottom
Then use the below code
*/
using System.Net.Mail;
using System.Net;
private static void SendMail()
{
var senderEmail = new MailAddress("donotreplygkce@gmail.com", "AlumniJobPortal");
var receiverEmail = new MailAddress("rupesh.konduru@gmail.com", "Receiver");
var body = "Check mail works Check it is HTML";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("your_mail_id", "your_password")
};
using (var mess = new MailMessage(senderEmail, receiverEmail)
{
Subject = "Sample Subject",
Body = body,
IsBodyHtml=true
})
{
smtp.Send(mess);
}
}
/*Go to your Gmail==> Google Account ==> On the left sie click security
==>Enable ON for the "Allow less secure apps",that is present in the bottom
Then use the below code
*/
using System.Net.Mail;
using System.Net;
private static void SendMail()
{
var senderEmail = new MailAddress("donotreplygkce@gmail.com", "AlumniJobPortal");
var receiverEmail = new MailAddress("rupesh.konduru@gmail.com", "Receiver");
var body = "Check mail works Check it is HTML";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("your_mail_id", "your_password")
};
using (var mess = new MailMessage(senderEmail, receiverEmail)
{
Subject = "Sample Subject",
Body = body,
IsBodyHtml=true
})
{
smtp.Send(mess);
}
}
No comments:
Post a Comment