I am getting a message in raw format . Then got the Mimemessage by
MimeMessage email = new MimeMessage(session, new ByteArrayInputStream(emailBytes));
Now email.getSubject is returning right value but email.getReceivedDate is null
Please explain this behaviour. Is this the right way to decode different parts of the mail
com.google.api.services.gmail.model.Message fullMessage = mService.users().messages().get(acct.sEmail, message.getId()).setFormat("raw").execute();
Properties props = new Properties();
idg.javax.mail.Session session = idg.javax.mail.Session.getDefaultInstance(props, null);
byte[] emailBytes = com.google.api.client.util.Base64.decodeBase64(fullMessage.getRaw());
try {
idg.javax.mail.internet.MimeMessage email = new idg.javax.mail.internet.MimeMessage(session, new ByteArrayInputStream(emailBytes));
Log.i("Received date","is" + email.getReceivedDate() + message.getId());
Log.i("subject", "is" + email.getSubject());
} catch (MessagingException e) {
e.printStackTrace();
}
yes you can use getReceivedDate()
for MimeMessage
and yes, ofcourse its the better way to retrieve the values for different parts of mail.
This is to retrieve MimeMessage
: Users MimeMessage
This is to get Different Properties of mail : MimeMessage Properties
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.