0
votes

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();
                }
1

1 Answers

0
votes

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