Resources » Code Snippets » Email

Send email using smtp object in c#


Posted Date:     Category: Email    
Author: Member Level: Gold    Points: 10



 


This is a sample code to send mail through any c# application.


using System.Web.Mail;

protected void SendEMail(string MailTo, string MailFrom, string MailSubject, string MailBody)
{
MailMessage objEmail = new MailMessage();
objEmail.To = MailTo;
objEmail.From = MailFrom;
objEmail.Subject = MailSubject;
MailBody = MailBody.Replace("\r\n", "
");
MailBody = MailBody.Replace("\t", " ");
objEmail.Body = MailBody;
objEmail.Priority = MailPriority.High;
objEmail.BodyFormat = MailFormat.Html;

try
{
SmtpMail.Send(objEmail);
}
catch (Exception exc)
{
Response.Write("Send failure: " + exc.ToString());
}
}






Did you like this resource? Share it with your friends and show your love!


Responses to "Send email using smtp object in c#"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Send Email From C#
    Previous Resource: Send Email using smtpClient
    Return to Resources
    Post New Resource
    Category: Email


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Email  .  
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.