Problem with Outlook displaying an html message
I am sending an html formatted email message using MailMessage class. Code is as follows:
MailMessage message = new MailMessage();
message.body = "<html>&开发者_运维百科lt;body><b>test message</b></body></html>";
message.IsBodyHtml = true;
....... skipped To/From settings - irrelevant .......
new SmtpClient().Send(message);
When I see this received message in Outlook, it shows the whole html:
<html>
<body>
<b>
test message
</b>
</body>
</html>
instead of just bolded text message.
What am I doing wrong?
1) If you're running Outlook 2003 on windows 7, there was a known issue when trying to render emails with "Undisclosed-recipients" set. A patch was released, can't seem to find it atm. Does this sound like it could be your problem?
2) Check your virus scanner is not causing the problem
3) Do HTML emails render correctly from other sources? If they aren't then perhaps something between the sender and the recipient (even if they are both you) might be causing the issue.
I actually fixed it by putting html version of the email into message.AlternateViews instead of message.Text
精彩评论