How to get full message body in Gmail?

后端 未结 7 1706
旧巷少年郎
旧巷少年郎 2020-12-16 15:07

I want to get full message body. So I try:

Message gmailMessage = service.users().messages().get(\"me\", messageId).setFormat(\"full\").execute();

7条回答
  •  既然无缘
    2020-12-16 15:34

    To get the data from your gmailMessage, you can use gmailMessage.payload.parts[0].body.data. If you want to decode it into readable text, you can do the following:

    import org.apache.commons.codec.binary.Base64;
    import org.apache.commons.codec.binary.StringUtils;
    
    System.out.println(StringUtils.newStringUtf8(Base64.decodeBase64(gmailMessage.payload.parts[0].body.data)));
    

提交回复
热议问题