-2

i nearly spent a day on it but couldn't fix it,

i am sending HTML within email body (asp.net 3.5) but problem is that it neither it takes div within body nor any inline style ,

message.Body = "<html>"+
                               "<body>"+
                                 "<div style=\"background-color:yellow;\">" +
                                  "<h3>"+
                                   " Congrats" + " " + userName + " " + " You have been shortlisted for interview. Please appear on " + " " + date +", "+time+" "+ "for interview"+
                                  "</h3>"+
                                 "</div>"+
                                "</body>"+
                               "</html>";

the tags for bold works well, / , but it doesn't take any style or even div tag within body, why ?

Hunain Hafeez
  • 71
  • 1
  • 1
  • 9
  • Can you include your full Send code? What email client are you checking in? Also consider [StringBuilder](http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx) when concatenating a lot of strings. Or in this case, maybe http://stackoverflow.com/questions/886728/generating-html-email-body-in-c-sharp – MikeSmithDev Feb 02 '13 at 00:41

1 Answers1

1

Set the IsHTML flag to true on the MailMessage.

markp3rry
  • 724
  • 10
  • 26
  • i already set that to true message.IsBodyHtml = true; but no effect :( – Hunain Hafeez Feb 01 '13 at 23:36
  • Post the full code for your method like @MikeSmithDev suggests. I seem to remember that this wasn't as straightforward as it should be and there were a couple of hoops you had to jump through. – markp3rry Feb 02 '13 at 19:21