【问题标题】:Sending HTML email but delivered as plain text, why?发送 HTML 电子邮件但以纯文本形式发送,为什么?
【发布时间】:2016-03-07 14:39:30
【问题描述】:

我正在使用 sendgrid,这是我的 java 代码:

public void sendEmail(String templateID){

    SendGrid sendgrid = new SendGrid("username", "password");

    Email email = new Email();

    email.addTo("...");
    email.addToName("...");
    email.setFrom("...");
    email.setSubject("...");
    email.setText("...");
    email.setTemplateId(templateID);

    try {
        sendgrid.send(email);
    } catch (SendGridException ex) {
        Logger.getLogger(FXMLEditNewsLetterController.class.getName()).log(Level.SEVERE, null, ex);
    }

}

邮件正在发送(我不知道为什么它们会被视为垃圾邮件!!)但它们是以纯文本形式发送的。 谁能帮助我,如果您需要任何其他信息,请告诉我。

【问题讨论】:

    标签: java smtp sendgrid


    【解决方案1】:

    电子邮件以纯文本形式发送,因为您使用的是 email.setText()。如果邮件的内容是 HTML,请尝试使用 email.setHtml()。

    【讨论】:

    • 谢谢...不敢相信这么简单。
    猜你喜欢
    • 2015-03-09
    • 2021-04-12
    • 2012-04-29
    • 2015-09-19
    • 1970-01-01
    • 2017-06-28
    • 2015-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多