如何在Android中获取gmail邮件主题?

时间:2015-10-21 17:19:58

标签: android email gmail

我想控制发送邮件的特定人员的电子邮件主题。我找到了一些关于它的代码,但我不知道如何控制电子邮件的主题。有谁知道我怎么能实现这个目标?谢谢。这是代码。

Properties props = new Properties();
//IMAPS protocol
props.setProperty(“mail.store.protocol”, “imaps”);
//Set host address
props.setProperty(“mail.imaps.host”, imaps.gmail.com);
//Set specified port
props.setProperty(“mail.imaps.port”, “993″);
//Using SSL
props.setProperty(“mail.imaps.socketFactory.class”, “javax.net.ssl.SSLSocketFactory”);
props.setProperty(“mail.imaps.socketFactory.fallback”, “false”);
//Setting IMAP session
Session imapSession = Session.getInstance(props);

Store store = imapSession.getStore(“imaps”);
//Connect to server by sending username and password.
//Example mailServer = imap.gmail.com, username = abc, password = abc
store.connect(mailServer, account.username, account.password);
//Get all mails in Inbox Forlder
inbox = store.getFolder(“Inbox”);
inbox.open(Folder.READ_ONLY);
//Return result to array of message
Message[] result = inbox.getMessages();

1 个答案:

答案 0 :(得分:0)

did not was looking是朋友。你需要下一个:

System.out.println("Subject: " + message.getSubject());