0
나는 단지 오래된 우편물을 얻는 부호를 달릴 것이다, 그러나 나는 새로운, 읽지 않은 우편물 인 특별한 주제가있는 우편물을 ..... 얻어야한다 ..... 무엇이 문제인가?JavaMail IMAP. 나는 최신 우편물을 얻지 않는다
감사
public static void dumpMail() throws FileNotFoundException, IOException, MessagingException, FolderClosedException, SocketTimeoutException {
Properties props = new Properties();
String username = "ad\\" + "x";
String password = "y";
props.put("mail.imaps.host", "z");
props.put("mail.imaps.port", "993");
props.put("mail.imaps.connectiontimeout", "10000");
props.put("mail.imaps.timeout", "10000");
props.put("host", "z");
props.put("user", username);
props.put("pass", password);
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("z", username, password);
Folder inbox = store.getFolder("inbox");
inbox.open(Folder.READ_ONLY);
Flags seen = new Flags(Flags.Flag.SEEN);
FlagTerm unseenFlagTerm = new FlagTerm(seen, false);
Flags recent = new Flags(Flags.Flag.RECENT);
FlagTerm recentFlagTerm = new FlagTerm(recent, true);
SearchTerm searchTerm = new AndTerm(unseenFlagTerm, recentFlagTerm);
Message[] messages = inbox.search(searchTerm);
for (int i = 0; i < 30; i++) {
if (messages[i].getSubject().contains("Zeiterfassung")) {
System.out.println(messages[i].getContent());
}
}
}