I’m writing a webmail product and some emails have body css that changes the background … so when I Html.Decode() that emailbody, it’s altering the CSS of the entire page.
Is there a good way to contain that problem?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can make your CSS more specific than the email’s rules. For example:
body.bodyis more specific than.bodyorbodyAny styles in body.body that clash with those in the lesser examples above, will override. But to stop the styles merging together, you’ll need to define every single style.
Alternatively you can go with rewriting the CSS in the emails, which is the way most webmail/desktop email clients go these days, one way or the other. If you prefix all the rules with
#emailMessage, for example, and place the email inside a<div id="emailMessage"></div>tag, all the styles in the email will only apply inside that namespace.Using an iframe to display emails only introduces more problems based around accessibility, etc etc. Good luck.