Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 ASP.NET
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 21:38pm
Comments
Reiss at 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 at 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 at 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 at 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 at 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
0 OriginalGriff 195
1 Afzaal Ahmad Zeeshan 132
2 ProgramFOX 130
3 Maciej Los 105
4 Sergey Alexandrovich Kryukov 75
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2014
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