简体   繁体   English

如何在电子邮件客户端和HTML网页之间保留HTML / CSS格式?

[英]How can I preserve HTML/CSS formatting between email client and HTML web page?

I have a client that uses Google Mail's IMAP library to read HTML email from a Gmail inbox, then uploads said email to a database for retrieval and display on a web page. 我有一个客户端,该客户端使用Google Mail的IMAP库从Gmail收件箱中读取HTML电子邮件,然后将所述电子邮件上载到数据库以进行检索并显示在网页上。 The idea is to have all company-wide emails available in a centralized location for reference by employees. 想法是在集中位置提供所有公司范围内的电子邮件,以供员工参考。

I have all the code working to grab the emails from Gmail, insert into the database, and display on the internet. 我的所有代码都可以从Gmail提取电子邮件,插入数据库并在Internet上显示。

The problem I am having is that when displaying the HTML emails on the website, the HTML inherits all sorts of CSS class, et al. 我遇到的问题是,当在网站上显示HTML电子邮件时,HTML会继承各种CSS类,等等。 definitions in place on the page and ruins the formatting of the original email. 页面上的定义不正确,并破坏了原始电子邮件的格式。 For example, a simple bulleted list from the email takes on a background color and specialized font. 例如,电子邮件中的一个简单的项目符号列表具有背景色和专用字体。 I have experimented with wkhtmltopdf to preserve formatting fidelity, but the customer wants the raw email on the page in it's original formatting rather than a linked PDF. 我已经尝试过使用wkhtmltopdf来保留格式保真度,但是客户希望页面上的原始电子邮件以其原始格式而不是链接的PDF。

Is there a way I can discard all inherited formatting and display the HTML email to the web page in it's original formatting? 有什么方法可以丢弃所有继承的格式,并以原始格式将HTML电子邮件显示到网页上?

You can display the email in an iframe. 您可以在iframe中显示电子邮件。

The iframe doesn't inherit the CSS from the calling parent, so your email is displayed with a clean css sheet. iframe不会从调用父级继承CSS,因此您的电子邮件将以干净的CSS表显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将HTML文件显示为网页? - How can I display an HTML file as a web page? 在我的Spring Boot Web应用程序中,如何在没有模板引擎的情况下发送包含html的电子邮件> - In my Spring Boot web application, how can I send an email containing html without a templating engine> 如何在保留格式的同时删除这些html元素? - How can I remove those html elements, while retain the formatting? 如何在不剥离格式设置的情况下将HTML转换为字符串? - How can I Convert Html to a String without stripping formatting settings? 我如何在一个html页面中获取包含的所有文件的总大小(递归为css文件)? - how can i get the total size of all files contained (recursively for css file )in one html page? 如何访问 html 页面中“Cänvas Id”中的 web 元素? - How can I access the web element present from the “Cänvas Id” in a html page? 如何在电子邮件正文中放置HTML链接? - How Can I put a HTML link Inside an email body? 我如何从Json Web响应中获取HTML格式? - How to use html formatting I am getting from a Json Web Response? 如何更改此更改以使用html页面替换404页面错误? - how can i change this to replace the 404 page error with a html page? 如何使用在html页面中创建的枚举类 - How can I use an enum class that I created in an html page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM