GMail API : unable to add an attachment in a draft

不打扰是莪最后的温柔 提交于 2019-12-01 14:09:43

I think that code is reasonable. Can you provide the output from the email.writeTo(System.out) to confirm? Seems like a bug in the Gmail API.

Is this repeatable for any specific user? (Does it always fail or will it eventually work?)

Does it happen for all users or only certain users (e.g. does it work for gmail.com users and not for Google Apps users)?

Problem solved by itself the next day ! I don't know if the GMail API team fixed something or if it was a temporary bug.

Try this hope so its works first put text content and after that html content its display properly

MimeBodyPart textPart = new MimeBodyPart();
        textPart.setText("This is actual message", "utf-8");

        MimeBodyPart htmlPart = new MimeBodyPart();
        htmlPart.setContent("<h1>This is a test</h1>"
                + "<img src=\"http://www.rgagnon.com/images/jht.gif\">", "text/html; charset=utf-8");
        Multipart multipart = new MimeMultipart();

        multipart.addBodyPart(textPart);<--first 
        multipart.addBodyPart(htmlPart);<--seocnd 
        message.setContent(multipart)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!