.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 >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

how to send Email

Posted By: Vikramraj     Posted Date: June 11, 2010    Points:2   Category :ASP.Net
I want to send Email from any emailid to any emailid in asp.net webpages c#.net how can i solve this problem

Responses
Author: Amit Mehra             
Posted Date: June 11, 2010     Points: 5   

HI,

You can use MailMessage class to send mail in asp.net. MailMessage class is available under System.Net.Mail namespace.

You can see sample code below

MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress(from);
mailMessage.To.Add(to);
mailMessage.Subject = subject;
mailMessage.IsBodyHtml = true;
mailMessage.BodyEncoding = Encoding.UTF8;
mailMessage.Body = body;
mailMessage.Priority = MailPriority.Normal;

// Smtp configuration for localhost / gmail
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("", ""); // enter your user name and password for gmail
client.Port = 25; //use 465 or 587 ports for gmail
client.Host = "localhost";//use "smtp.gmail.com" for gmail
client.EnableSsl = false; // true for gmail

MailMessage message = mailMessage;

try
{
client.Send(message);
}
catch (Exception ex)
{
Throw ex;
}


Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Syed Shakeer Hussain             
Posted Date: June 20, 2010     Points: 5   
Author: Nikhil Kumar             
Posted Date: August 09, 2010     Points: 5   

For a proper descriptive article on sending email in asp.net read this

http://dotnetask.blog.co.in/2009/09/16/send-e-mail-in-aspnet/

Thanks

Be helpful and enjoy life because it comes only onces. Give all the happiness to yours and remember it doesn't comes by money ...


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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