I am using javamail IMAP but I dont know how to get Sent or another folder except inbox -
i trying sent folder in gmail. it's depend on language. ex, if used english tree list below:
[gmail]/all mail [gmail]/bin [gmail]/drafts ....
but if use other language, folder translated language. try create index folder it's not successful because folder sorted follow alphabet. can't hardcode : getfolder("[gmail]/sent mail")
, in other language "sent mail translated. have question. can name of folder how recognize "sent mail" folder mail sent.
gmail folders have attributes , can rely on them folder want (if it's 1 of standard ones).
so, if
store.getdefaultfolder().list("*");
you folders, not first level. , response server should looks this:
a3 list "" "*" * list (\hasnochildren) "/" "inbox" * list (\noselect \haschildren) "/" "[gmail]" * list (\hasnochildren \all) "/" "[gmail]/all mail" * list (\hasnochildren \drafts) "/" "[gmail]/drafts" * list (\hasnochildren \important) "/" "[gmail]/important" * list (\hasnochildren \sent) "/" "[gmail]/sent mail" * list (\hasnochildren \junk) "/" "[gmail]/spam" * list (\hasnochildren \flagged) "/" "[gmail]/starred" * list (\hasnochildren \trash) "/" "[gmail]/trash" * list (\hasnochildren) "/" "[gmail]trash"
once the list of folders can iterate them looking attribute want. if looking sent folder this:
public folder getsentfolder(folder[] folders) throws messagingexception { (folder folder : folders) { imapfolder imapfolder = (imapfolder) folder; for(string attribute : imapfolder.getattributes()) { if ("\\sent".equals(attribute)) { return folder; } } } return null; }
and have folder selector language agnostic.
note works because gmail. other email servers may not have attributes
Comments
Post a Comment