简体   繁体   中英

html email with inline image shows junk character in IPhone6s but not in Iphone5s,sending email through JAVA

I am sending inline image email through java,which is working in gmail,yahoo email,except apple mail(9.3.2),working in apple mail(9.0).It is showing junk character in apple mail(9.3.2). Can any one suggest why it is happening?

MimeBodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setContent(htmlBody,"text/html; charset=UTF-8");

 // creates multi-part
 Multipart multipart = new MimeMultipart();
 multipart.addBodyPart(messageBodyPart);

 // adds inline image attachments
if (mapInlineImages != null && mapInlineImages`*enter code here*`.size() > 0) {

     Set<String> setImageID = mapInlineImages.keySet();

     for (String contentId : setImageID) {
         MimeBodyPart imagePart = new MimeBodyPart();
         imagePart.setHeader("Content-ID", "<" + contentId + ">");
         imagePart.setDisposition(MimeBodyPart.INLINE);
         String imageFilePath = mapInlineImages.get(contentId);
         try {
             imagePart.attachFile(imageFilePath);
         } catch (IOException ex) {
             log.error(ex.getMessage());
         }

         multipart.addBodyPart(imagePart);
     }
 }
 if(attachments!=null){
 multipart.addBodyPart(messageBodyPart1);
 }
 message.setContent(multipart);

 Transport.send(message);

Hard to know if this is the problem without seeing the code or an example of what's wrong, but there is a bug in iOS 9 (iPhone 6S) that will sometimes scramble an image if the width and height are not explicitly set. This issue usually goes away if you close and reopen the email, so that might clue you in as to whether or not this is the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM