Note that there are some explanatory texts on larger screens.

plurals
  1. POJavamail performance
    text
    copied!<p>I've been using javamail to retrieve mails from IMAP server (currently GMail). Javamail retrieves list of messages (only ids) in a particular folder from server very fast, but when I actually fetch message (only envelop not even contents) it takes around 1 to 2 seconds for each message. What are the techniques should be used for fast retrieval?</p> <p>here is my code:</p> <pre><code> try { IMAPStore store = null; if(store!=null&amp;&amp;store.isConnected())return; Properties props = System.getProperties(); Session sessionIMAP = Session.getInstance(props, null); try { store = (IMAPStore) sessionIMAP.getStore("imaps"); store.connect("imap.gmail.com",993,"username@gmail.com","password"); } catch (Exception e) { e.printStackTrace(); } IMAPFolder folder = (IMAPFolder) store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); System.out.println("start"); Message[] msgs = folder.getMessages(1,10); long ftime = System.currentTimeMillis(); FetchProfile fp=new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE); folder.fetch(msgs, fp); long time = System.currentTimeMillis(); System.out.println("fetch: "+(time-ftime)); for (Message message : msgs) { System.out.println(message.getSubject()); Address[] from = message.getFrom(); for (Address address : from) { System.out.println(address); } Address[] recipients = message.getAllRecipients(); for (Address address : recipients) { System.out.println(address); } } long newTime = System.currentTimeMillis(); System.out.println("convert: "+(newTime-time)); }catch (Exception e) { e.printStackTrace(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload