简体   繁体   English

如何在java邮件中提供内联样式css?或者如何在java邮件中包含CSS?

[英]How to give inline style css in java mail?or How to include CSS in java mail?

How to give inline style css in java mail? 如何在java邮件中提供内联样式css? or How to include CSS in java mail? 或者如何在java邮件中包含CSS?

The first thing you need to do is indicate that you will be sending html and not plain text. 您需要做的第一件事是表明您将发送HTML而不是纯文本。 You can do this by setting the content type: 您可以通过设置内容类型来执行此操作:

message.setContent(text, "text/html; charset=utf-8");

Once you do that you can use CSS in your email body content. 完成后,您可以在电子邮件正文内容中使用CSS。 Be careful as not all the features of CSS are available for your use in an email. 请注意,并非CSS的所有功能都可供您在电子邮件中使用。 See http://www.sitepoint.com/how-to-code-html-email-newsletters/ for more 有关更多信息,请访问http://www.sitepoint.com/how-to-code-html-email-newsletters/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM