我正在开发一个与电子邮件相关的应用程序。
我使用以下代码来查找收件箱邮件信息。
private void initProtocol() {
EmailAuthenticator authenticator = new EmailAuthenticator(account);
Properties props1 = new Properties();
props1.setProperty("mail.transport.protocol", "smtps");
props1.setProperty("mail.host", stmpHost);
props1.put("mail.smtp.auth", "true");
props1.put("mail.smtp.port", "465");
props1.put("mail.smtp.socketFactory.port", "465");
props1.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props1.put("mail.smtp.socketFactory.fallback", "false");
props1.setProperty("mail.smtp.quitwait", "false");
smtpSession = Session.getDefaultInstance(props1, authenticator);
Properties props2 = new Properties();
props2.setProperty("mail.store.protocol", "imaps");
props2.setProperty("mail.imaps.host", mailServer);
props2.setProperty("mail.imaps.port", "993");
props2.setProperty("mail.imaps.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props2.setProperty("mail.imaps.socketFactory.fallback", "false");
imapSession = Session.getInstance(props2);
}
public void getInboxMails() throws MessagingException {
store = imapSession.getStore("imaps");
store.connect(mailServer, account.username, account.password);
inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_ONLY);
Message[] messages = inbox.getMessages();
for (int i = messages.length - 1; i >= 0; i--)
{
Part p = messages[i];
try {
String subject = messages[i].getSubject();
Log.v("info","subject="+subject);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return ;
}
工作正常。
但我希望收到邮件信息。
如果任何机构知道如何获取发送邮件信息的解决方案。
请提前帮助我。