本文介绍了如何在 Gmail 中获取完整的邮件正文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得完整的消息正文.所以我尝试:
I want to get full message body. So I try:
Message gmailMessage = service.users().messages().get("me", messageId).setFormat("full").execute();
为了得到身体,我尝试:
That to get body, I try:
gmailMessage.getPayload().getBody().getData()
但结果总是null
.如何获取完整的邮件正文?
but result always null
. How to get full message body?
推荐答案
要从您的 gmailMessage 中获取数据,您可以使用 gmailMessage.payload.parts[0].body.data.如果要将其解码为可读文本,可以执行以下操作:
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)));
这篇关于如何在 Gmail 中获取完整的邮件正文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!