Getting mail from GMail into Java application using IMAP
Using imaps was a great suggestion. Neither of the answers provided just worked for me, so I googled some more and found something that worked. Here’s how my code looks now. Properties props = System.getProperties(); props.setProperty(“mail.store.protocol”, “imaps”); try { Session session = Session.getDefaultInstance(props, null); Store store = session.getStore(“imaps”); store.connect(“imap.gmail.com”, “<username>@gmail.com”, “<password>”); … } catch (NoSuchProviderException … Read more