Search code examples
c#imapimapx

Filter by multiple subjects IMAPX


Is there any way to filter the messages' downloading by more than one specific subject?

For example, I need to download only the messages which contain "for 10" or "for 11" in their respective subjects.

With one subject it's clear:

folderSearchMessages.Messages.Download("SUBJECT for 10", messageFetchMode, numMessages)

By the way, where could I look for deeper documentation? Rather than the official page.


Solution

  • Not an IMAPX user, but if it's free form text in the search string, you can just use the IMAP search language, detailed in RFC3501 §6.4.4. If your server supports search correctly (there are a lot that don't), you can use an OR term:

    folderSearchMessages.Messages.Download("OR (SUBJECT \"for 10\") (SUBJECT \"for 11\")", messageFetchMode, numMessages)
    

    Note that you should also quote your strings.