Some questions related to implementation of image inside email signature?

前端 未结 2 418
温柔的废话
温柔的废话 2021-01-03 17:25

i need to implement the email signature with image.As of now we only support the text in email signature which is already working.i need to provide the functionality where

2条回答
  •  长情又很酷
    2021-01-03 18:13

    For Gmail to see the embedded image from byte array, I posted an answer on another similar question which is to use ByteArrayDataSource and embed it to the HtmlEmail. Here's the code snippet:

    import javax.mail.util.ByteArrayDataSource;
    import org.apache.commons.mail.ImageHtmlEmail;
    ...
    ImageHtmlEmail email = new ImageHtmlEmail();
    byte[] qrImageBytes = createQRCode(); // get your image byte array
    ByteArrayDataSource qrImageDataSource = new ByteArrayDataSource(qrImageBytes, "image/png");
    String contentId = email.embed(qrImageDataSource, "QR Image");
    

提交回复
热议问题