我可以从此代码中访问JavaMail API
的电子邮件
public Folder getMails() throws MessagingException {
store = imapSession.getStore("imaps");
store.connect(mailServer, account.username, account.password);
inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_WRITE);
Message[] result = inbox.getMessages();
return inbox;
}
我可以在ListView中显示主题现在我的问题是 1.如何在Android中显示电子邮件内容正文。 &安培; 2 。我想访问Yahoo邮箱&微软电子邮件等。我也可以通过JavaMail API访问这些电子邮件。我已经看到了这个K-9 mail,但我无法导入它。
任何帮助都会得到赞赏, 在此先感谢。
答案 0 :(得分:1)
1您可以使用WebView来显示消息内容,因为它会自动为您呈现HTML
,并且还会提供缩放功能。
2您可以从任何邮件服务器访问邮件,只需要正确的属性即可
例如,在实时和Hotmail的情况下,主机将为pop3.live.com
,协议将为pop3s
,因为MS服务器不支持IMAP。
另请注意:Yahoo的免费版本不允许第三方服务访问消息。如果使用他们的高级服务Yahoo!,您只能访问来自Yahoo的消息。加。
答案 1 :(得分:0)
答案 2 :(得分:0)
尝试使用以下代码来获取邮件内容
private static String getMailContent(Multipart multipart) throws IOException, MessagingException{
StringBuffer content = new StringBuffer();
for (int x = 0; x < multipart.getCount(); x++) {
BodyPart bodyPart = multipart.getBodyPart(x);
String disposition = bodyPart.getDisposition();
if (disposition != null && (disposition.equals(BodyPart.ATTACHMENT))) {
// ................................
} else {
content.append(bodyPart.getContent());
}
}
return content.toString();
}