Search code examples
emailoutlookimapoutlook.com

Does IMAP search work on outlook.com


I'm new to IMAP.

I'm trying to fetch mails from outlook.com, I have configured outlook.com IMAP settings in my email client. I'm able to connect and get messages from outlook.com.

But when I'm trying to get messages by using search term like

I'm using Java mail packages.

IMAPStore store = getStore(serverName, userName, password, port);
IMAPFolder inboxFolder = (IMAPFolder) store.getFolder("INBOX");

SearchTerm[] searchTerms = new SearchTerm[4];

Address address = new InternetAddress("search_email_address");
SearchTerm toTerm = new RecipientTerm(Message.RecipientType.TO, address);
SearchTerm ccTerm = new RecipientTerm(Message.RecipientType.CC, address);
SearchTerm bccTerm = new RecipientTerm(Message.RecipientType.BCC, address);
SearchTerm fromStringTerm = new FromStringTerm(searchEmail);

searchTerms[0] = toTerm;
searchTerms[1] = ccTerm;
searchTerms[2] = bccTerm;
searchTerms[3] = fromStringTerm;

OrTerm orTerms = new OrTerm(searchTerms);

inboxFolder.search(orTerms);

I'm trying to search mails using like above search terms in a IMAP folder, but I'm getting zero mails.

Any API limitations in this or any problems in code, please guide me

Thanks Ramesh


Solution

  • Looking at the question "Does IMAP search work on outlook.com" I can say: Yes.

    I'm using imapsync to sync from outlook.com to other mailboxes and it works. Behind the scenes imapsync uses IMAP searches.

    The IMAP capabilities announced by outlook.com are:

    IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CLIENTACCESSRULES CLIENTNETWORKPRESENCELOCATION BACKENDAUTHENTICATE CHILDREN IDLE NAMESPACE LITERAL+ AUTH

    Maybe this helps somebody. This could also explain why certain search keywords might or might not work.