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


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Email >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Sending email with C#

Posted By:Shashi Ray       Posted Date: September 02, 2008    Points: 10    Category: Email    URL: http://www.dotnetspark.com  

Sending email with C#. Sending mail is the an important feature of some application. .NET Framework provides MailMessage Class
 

Sending mail is the an important feature of some application. .NET Framework provides MailMessage Class could be find under System.Web.Mail or System.Net.Mail .

Below is the code used Ststem.Net.Mail's MailMessage class to send Mail in ASP.NET.

using System.Net.Mail;

Make sure that you have added the System.Net.Mail Namesapace on the top of the page

MailMessage message = new MailMessage();
message.Form = new MailAddress"shashikantray@gmail.com");
message.To.Add(new MailAddress("shashikantray@yahoo.com"));
message.Subject="This is my subject";
message.Body="This is the content";
message.BodyEncoding=System.Text.Encoding.ASCII;
SmtpClient client = new SmtpClient("localhost");
clint.Host="data01";
clint.Port=25;
clint.Send(message);

Hope the above isĀ  useful to all the people who want to send mail from their application in asp.net


     

Further Readings:

Responses

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