Hi to all,
How to send a mail from asp.net application using C#.net
Loading
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 attend5days leftRegister
Roei BarRank #1,271 · 1.4K reputationPosted Aug 3, 2009, 10:47 AM EDT
you can use smtpclient,
here is a sample code:
void SendEMail(string from, string to, string subject, string body)
{
try
{ // Construct a new e-mail message
SmtpClient client = new SmtpClient(smtpClient);
client.Send (from, to, subject, body);
}
catch (SmtpException ex)
{
MessageBox.Show ( ex.Message, "SendEMail: " + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error );
}
}
enjoy
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Aug 3, 2009, 9:56 PM EDT
1. http://www.aspnettutorials.com/tutorials/email/email-auth-aspnet2-csharp.aspx
2. http://www.developer.com/net/asp/article.php/3096831
3. http://www.dotnetspider.com/resources/22633-HOW-TO-SEND-AND-EMAIL-FROM-ASP-NET-APPLICATION.aspx
Deependra Khangarot199 reputationPosted Aug 5, 2009, 9:42 PM EDT
Posted Aug 7, 2009, 1:19 AM EDT
SmtpClient smtp = new SmtpClient();
smtp.UseDefaultCredentials = true;
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add( new MailAddress( ToemailAdresss,
ToDisplayname);
//create the mail message
mailMessage.Subject = subject;
mailMessage.Body = messageBody;
mailMessage.From = new MailAddress( fromEmailAddress,
fromDisplayName );
smtp.Send( mailMessage );