Click here to Skip to main content
12,951,619 members (55,807 online)
Rate this:
 
Please Sign up or sign in to vote.
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 8-Sep-11 20:38pm
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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 );
  Permalink  
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
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
MaulikDusara 9-Sep-11 3:36am
   
which error are you getting.. and in mentioned article there is source code also available
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

<pre lang="c++">><
  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,084
CHill60 3,480
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,830


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100