How to Send Mail in ASP.NET using C# ?
How to Send Mail in ASP.NET using C# ? Please help me.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 1, 2013, 3:44 AM EDT
I've created a sample code for you, please see below. This sample is specific to using Gmail. You're free to use any email service provider. You need to set the SMTP Domain Name, Port and EnableSSL (to specify it supports SSL or not, like Gmail does).
-----------------------------------------------------------
private bool SendEmail()
{
bool EmailSent = false;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("[email protected]", "yourPasswordHere");
MailMessage message = new MailMessage("[email protected]", "[email protected]");
message.IsBodyHtml = true;// If you want to send HTML contents;
message.Body = "
Hi!
This is a test mail.
";Thanks
try
{
smtp.Send(message);
EmailSent = true;
}
catch (Exception ex)
{
// Handle the exception here
}
return EmailSent;
}
Also, a true false is implemented to return in case you might want to check if the email was sent successfully.
Happy Coding :)
Please don't forget to accept this as answer if it help!
Thanks.
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Jun 1, 2013, 3:48 AM EDT
Please go throgh these link
http://www.c-sharpcorner.com/uploadfile/anjudidi/send-multiple-email-at-the-same-time-in-Asp-Net-with-attached-file/
http://www.c-sharpcorner.com/UploadFile/ed8f22/send-mail-using-gmail-yahoo-account-in-VB-Net-and-C-Sharp-net/
http://www.c-sharpcorner.com/UploadFile/deepak.sharma00/send-email-from-C-Sharp-windows-application-using-gmail-smtp/
Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 1, 2013, 11:10 PM EDT
http://www.c-sharpcorner.com/Blogs/11152/sending-email-with-html-body-in-Asp-Net-and-list-of-smtp-hos.aspx
Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 3, 2013, 3:37 AM EDT
please reffer this
http://www.c-sharpcorner.com/Blogs/11152/sending-email-with-html-body-in-Asp-Net-and-list-of-smtp-hos.aspx
or
TO Run this program you need
Anna Harris36 reputationPosted Jun 4, 2013, 4:52 AM EDT