Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get full message body in 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()

but result always null. How to get full message body?

like image 566
somebody Avatar asked Jan 19 '15 13:01

somebody


People also ask

Why can't I see the whole message in Gmail?

1) Your email is larger than 102KB. Gmail will automatically clip any messages that exceed that size. The limit is based on the content in the HTML code. This will include formatting, text, URLs (including link tracking and images) and more.

How do I see full messages in Gmail?

Open the email message in Gmail, then select the More menu to display additional options. Select Show original from the menu. Gmail opens a new tab that shows the full message.

What is Gmail mail body?

Body. The body is the actual text of the email. Generally, you'll write this just like a normal letter, with a greeting, one or more paragraphs, and a closing with your name.


1 Answers

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)));
like image 171
Tholle Avatar answered Sep 29 '22 09:09

Tholle