I have a code snippet for deleting emails from Gmail. But I need to change that line store.getFolder("[Gmail]/Trash");
to work with the Outlook server.
What is the deleted(trash) folder name link for Outlook?
store = session.getStore("imaps"); store.connect("imap.gmail.com",<username>,<password>); inbox = store.getFolder("Inbox"); inbox.open(Folder.READ_WRITE); deletedMessages.add(message); message.setFlag(Flag.SEEN,true); if (inbox.isOpen()) { if(deletedMessages.size() > 0){ trash = store.getFolder("[Gmail]/Trash"); Message[] tempMessageArray = deletedMessages.toArray(new Messag e[deletedMessages.size()]); inbox.copyMessages(tempMessageArray,trash); deletedMessages.clear(); } inbox.close(true);
Advertisement
Answer
In Outlook, there are two options:
So you could use [Outlook]/Deleted Items
or [Outlook]/Junk Email
. Probably most comparable to [Gmail]/Trash
is [Outlook]/Deleted Items
. Junk Email
catches additional Spam email not blocked by Outlooks filters.