Click here to Skip to main content
15,886,654 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am try to send email in html body format but it not working.
I am using "System.Net.Mail" namespace and i also set MailMessage property IsBOdyHtml true.
Posted
Comments
Reiss 9-Sep-11 2:44am    
We need more details in order to help - can you detail the exception (if any) you are getting, along with the relevant code section

Hi,
After setting IsBodyHTMl true,you'll have to make the body HTML check the code

string text= "<table><tr><td>EmpId</td><td>Emp name</td><td>age</td></tr><tr><td>value</td><td>value</td><td>value</td></tr></table>"
MailMessage mail = new MailMessage();
mail.To ="me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.IsBodyHtml=true; 
mail.Body = text;
MailAttachment attachment = new MailAttachment( Server.MapPath( "test.txt" ) ); 
mail.Attachments.Add( attachment );	//add the attachment
SmtpMail.SmtpServer = "smtp.gmail.com";  //your real server goes hereSmtpMail.Send( mail );
 
Share this answer
 
Comments
Sumit Kumar Singh India 9-Sep-11 3:02am    
Hi Syed Salman Raza Zaidi,

still it not working. if i send simple text it worked fine but not with html content.
Syed Salman Raza Zaidi 9-Sep-11 3:23am    
Check this http://www.systemwebmail.com/faq/2.2.aspx
And
http://www.aspheute.com/english/20000918.asp

 
Share this answer
 
Comments
Sumit Kumar Singh India 9-Sep-11 3:00am    
Hi MaulikDusara,

for this code we need to System.Web.Mail namespace and it not working in my project, i don't know why
[no name] 9-Sep-11 3:36am    
which error are you getting.. and in mentioned article there is source code also available
<pre lang="c++">><
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900