I’m trying to download only subject of emails, because it should take less time (downloading ~10 emails with photos take approximately 10 min :/).
Code that I’m now using is:
try { Store store = session.getStore("imaps"); store.connect(...); Folder folder = store.getFolder(folderName); folder.open(Folder.READ_ONLY); message = folder.getMessages(); for (Message m : message) { System.out.println(m.getSubject()); } folder.close(false); store.close(); } catch (MessagingException e) { ... } catch (IOException e) { ... }
it seems to me that you should look into prefetching the messages with:
FetchProfile fp = new FetchProfile();fp.add(FetchProfile.Item.ENVELOPE);fp.add("Subject");folder.fetch(message, fp);
No comments:
Post a Comment