JAVA Mail-Outlook问题(使用GSuite配置)

时间:2019-02-28 12:23:53

标签: java outlook javamail

具有不同图像的同一封邮件发送给(MAIL.TO)不同的用户,而CC和BCC保持不变 Gmail和其他平台显示的图片正确(邮件正文),而在Outlook中查看时,其用户的图片却发生了更改(如果有多封邮件-CC和BCC)

    BodyPart messageBodyPart = new MimeBodyPart();
    MimeMultipart multipart = new MimeMultipart(/* "related" */);

    messageBodyPart.setContent(mailTemplateValue.getTemplate(), "text/html");
    multipart.addBodyPart(messageBodyPart);

    // first image
    messageBodyPart = new MimeBodyPart();
    DataSource employeeImage = new ByteArrayDataSource(dbResult.getImageData(), dbResult.getImageType());
    messageBodyPart.setDataHandler(new DataHandler(employeeImage));
    messageBodyPart.setHeader("Content-ID", "<employeeimage>");
    multipart.addBodyPart(messageBodyPart);

    // second image
    messageBodyPart = new MimeBodyPart();
    DataSource birthdayImage = new ByteArrayDataSource(convertImageToByteArray(birthdayImagePath),
            birthdayTemplateImageType);
    messageBodyPart.setDataHandler(new DataHandler(image2));
    messageBodyPart.setHeader("Content-ID", "<image2>");
    multipart.addBodyPart(messageBodyPart);

    // third image
    messageBodyPart = new MimeBodyPart();
    DataSource wishTextmage = new ByteArrayDataSource(convertImageToByteArray(birthdayWishTextImagePath),
            birthdayTemplateImageType);
    messageBodyPart.setDataHandler(new DataHandler(thirdimage));
    messageBodyPart.setHeader("Content-ID", "<thirdimage>");
    multipart.addBodyPart(messageBodyPart);

    // fourth image
    messageBodyPart = new MimeBodyPart();
    DataSource footerImage = new ByteArrayDataSource(convertImageToByteArray(birthdayFooterImagePath),
            birthdayTemplateImageType);
    messageBodyPart.setDataHandler(new DataHandler(footerImage));
    messageBodyPart.setHeader("Content-ID", "<footerimage>");
    multipart.addBodyPart(messageBodyPart);

    // put everything together
    message.setContent(multipart);
}

Transport.send(message);

0 个答案:

没有答案