[英]Android : Getting email message with gmail-api
I am getting a message in raw format . 我收到的是原始格式的消息。 Then got the Mimemessage by
然后得到了Mimemessage
MimeMessage email = new MimeMessage(session, new ByteArrayInputStream(emailBytes));
Now email.getSubject is returning right value but email.getReceivedDate is null 现在email.getSubject返回正确的值,但email.getReceivedDate为空
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. 是的,您可以对
MimeMessage
使用getReceivedDate()
,是的,当然,它是检索邮件不同部分的值的更好方法。
This is to retrieve MimeMessage
: Users MimeMessage 这是为了检索
MimeMessage
: 用户MimeMessage
This is to get Different Properties of mail : MimeMessage Properties 这是为了获得邮件的不同属性: MimeMessage属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.