2

I'm trying to send an html email to a gmail account, but for some reason, Google is stripping away the html from my email. The Html is preserved when I send to other accounts (non-gmail accounts) so I know that my html is correct.

Here's how I'm going about it:

  1. I have an aspx page, that I use as an email template.
  2. I grab the html from the aspx page from within a web service (done in C#)
  3. Dynamically fill in the non-static content through c# code within the web service.
  4. Send that as the email body.

Does anyone happen to know why gmail is removing the html? Thanks in advance.

1
  • 1
    Share the minimally non-working code here. Commented Aug 7, 2010 at 14:40

2 Answers 2

2

You need to be sure to set the IsBodyHtml property to true on your MailMessage:

var message = new MailMessage();
message.IsBodyHtml = true;
// Fill and send message here

Check out the MSDN reference for more info:

System.Net.Mail.MailMessage Members

Sign up to request clarification or add additional context in comments.

Comments

0

The Html is preserved when I send to other accounts (non-gmail accounts) so I know that my html is correct.

It's not a programming issue. If it were, as you've observed, this would happen to all clients.

The issue is this: Most modern email clients allow users to choose to disallow html messages, or always view them as plain text. That could be what is happening here. You have to code to expect this, because you can't control user's preferences. If they have this enabled, and you send it as html only, it will look ugly to them.

However, for a solution to your issue, you should always be sending your mail as a Multi-Part Mime message to allow all clients to get a nice readable version.

1 Comment

Thanks David. I'll be sure to make sure it's Multi-Part Mime

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.