.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Send Email from asp.net

Posted By:Hiren Soni       Posted Date: August 31, 2010    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

Send Email from asp.net

using System.Net.Mail;

String userName = "your username";

String passWord = "your password";

String sendr = "your email id";

String recer = "receiver of email";

String subject = "subject of email";

String body = "body part of email";

MailMessage msgMail = new MailMessage(sendr, recer, subject, body);

int PortNumber = 587; // port number

SmtpClient smtp = new SmtpClient("smtpservername", PortNumber);

msgMail.IsBodyHtml = true;
// if your body contains html tag

smtp.EnableSsl = true;

smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

smtp.Credentials = new System.Net.NetworkCredential(userName, passWord);





catch (Exception exp)


// error handling



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend