How to get full message body in Gmail?(如何在 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 中获取完整的邮件正文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Gmail 中获取完整的邮件正文?
基础教程推荐
- 存储 20 位数字的数据类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
