How to send a formated mail in ASP.Net

Send HTML Formated e-mail in ASP.Net

Send email with ASP.Net is easy task,
If you want to send email with HTML format, you must write this line in code : message.IsBodyHtml = true;

The code for simple send email is belows :

<%@ Import Namespace=”System.Net.Mail” %>

protected void Page_Load(object sender, EventArgs e)
{
//create the email message
MailMessage email = new MailMessage();
//set the from addresses
email.From = new MailAddress(“meeraacademy@hotmail.com”);

//set the to Address
email.To.Add(“meeraacademy@hotmail.com”);

//set the email subject and body , message
email.IsBodyHtml = true;
email.Subject = “Subject of Email – MeeraAcademyl”;
email.Body = “This is the Body of Email / Message of Email.”;

//send the message using smtpclient
SmtpClient smtp = new SmtpClient(“localhost”);
smtp.Send(mail);
lblmsg.Text = “Send Mail Successfullyt”;
}

The code for HTML formated email is belows :

all the things/code are same as above only code has been changed ::

email.IsBodyHtml = true;

email.Body = “<html><table border=’1′ bordercolor=’#003300′ style=’z-index: 100; left: 376px; width: 616px;position: absolute; top: 10px’>
<tr><td bgcolor=’#9b0033′ style=’width: 75px; text-align: center’><strong><span style=’font-size: 35px; color: #ffffff; font-family: Tahoma’>
MeeraAcademy.com</span></strong></td></tr><tr style=’font-size: 12pt’><td rowspan=’2′ style=’width: 75px; height: 312px’ valign=’top’><br />
<span style=’font-size: 11pt; font-family: Tahoma’><strong><span style=’color: #990033′><span style=’font-size: 15px’>
Thanks for registering with meeraacademy.com.</span><br /></span><br /><br /></strong><strong>
<span style=’color: #990033′>Your meeraacademy UserName: Hello</span> <br /><span style=’color: #990033′>your meeraacademy password : Meera
</span><br /><span style=’color: #990033′>If you have any questions or problems, please contact us from meeraacademy.com
</span><br /><span style=’color: #990033′>Thanks,<br />
<a href=’http://meeraacademy.com’>www.meeraacademy.com</a>
</span></strong></span></td></tr></table></html>”

The output is like :

 

Send formated email with ASP.Net

 

Here another Example of Formated Email ::

email.IsBodyHtml = true;

email.Body =”<html><table border=’1′ bordercolor=’#003300′>
<tr><td>Hello MeeraAcademy</td></tr><tr><td>Welcome to meeraacademy</td></tr>
</table></html>”

 

Send formated email with ASP.Net

Send formated email with ASP.Net

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

2 + 7 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">