Java Mail + HTML标记 [英] Java Mail + HTML tags

查看:72
本文介绍了Java Mail + HTML标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用javamail发送通知邮件,并且我需要呈现的消息文本有一个表.我的问题是当收到邮件时,我需要在邮件中显示此表结构.

反正我可以做到这一点.

我的消息文本代码是这样的

Hi,
I am sending a notification mail using the javamail and the message text which i need to render has a table. My problem is when the mail is received, i need to show this table structure in the mail.

Is there anyway i can do this.

My message text code goes like this

messageText.append("Dear Approver,");
            messageText.append("\n");
            messageText.append("The following lounge information changes are waiting for your approval");
            messageText.append("\n");
            messageText.append("<table>");
            messageText.append("<tr>");
            messageText.append("<td>Airline Code</td>");
            messageText.append("</tr>");
            messageText.append("</table>");




但该消息显示为




but it shows the message as

Dear Approver,
The following lounge information changes are waiting for your approval
<table><tr><td>Airline Code</td></tr></table>



---------
基本上,我想用发送消息时设置的内容来呈现表.
任何帮助将不胜感激.



---------
Basically i want to render a table with the content i set when the message is sent.
any help will be greatly appreciated.

推荐答案

您应将正文设置为HTML而不是Text(通常是默认设置).
请参考以下链接使用Java发送基于HTML的电子邮件 [
You should make the body as HTML instead of Text(mostly which is default).
Refer following link Sending HTML based email using Java[^]


这篇关于Java Mail + HTML标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆