问题
发出来的邮件是这个样子的
解决
问题在setText()
方法上
通过查看源码,我们可以发现有两个setText()
方法
分别是setText(String text)
和setText(String text, boolean html)
通过注释,我们发现
- 当
html
为true
时,表示传的内容是text/html
类型 - 当
html
为false
时,表示传的内容是text/plain
类型
而setText(String text)
实际上就调用了setText(String text, boolean html)
方法,并传给html
一个false
也就是说setText(String text)
默认表示传的内容是text/plain
类型
因此
我们给helper.setText(emailContent)
加上参数true