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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anna HarrisPosted Jun 4, 2013, 8:52 AM
Pankaj PandeyPosted Jun 3, 2013, 7:37 AM
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
Pankaj PandeyPosted Jun 2, 2013, 3:10 AM
http://www.c-sharpcorner.com/Blogs/11152/sending-email-with-html-body-in-Asp-Net-and-list-of-smtp-hos.aspx
Sandeep Singh ShekhawatPosted Jun 1, 2013, 7:48 AM
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/
Sunny SharmaPosted Jun 1, 2013, 7:44 AM
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.