Search code examples
androidgmail-imapjakarta-mail

how to read Sent Mails of gmail using javaxmail android


How can I get mails from Sent Mail folder of gmail? I can get mails from inbox using

store = imapSession.getStore("imaps");
store.connect("imap.gmail.com", user, password);
Folder folder = store.getFolder("Inbox");

I have tried,

Folder folder = store.getFolder("Sent");
//and
Folder folder = store.getFolder("AllMail");

but none of this is working, I'm getting a FolderNotFoundException.


Solution

  • The GMail folders for Sent, Drafts and so on, are prefixed with the tag [Gmail], so for the Sent Mail, it would be accessed like so:

    Folder folder = store.getFolder("[Gmail]/Sent Mail");
    

    Link:
    Gmail folders in your mail client