ImapClient: Listing Messages with Attachments without Fetching Them

Hi There,

I am using Aspose.Email v21.04.
I am trying to list images from a certain folder, but only those which hold attachments.
I did not see any option to add it to query while calling the API:
imapClient.ListMessages(folderName, query, itemsPerPage).
So right now I am using the API
var message = imapClient.FetchMessage
and then checking if message.Attachments.Count > 0 for each message in folder.
It’s a big overhead in terms of performance.
Is there another way to filter messages without calling FetchMessage?

@Orenk9,
Thank you for posting the query. Unfortunately, I did not find such a capability in Aspose.Email. I added a ticket with ID EMAILNET-40333 in our tracking system. Our development team will consider implementing this feature. I will inform you of any progress.

The issues you have found earlier (filed as EMAILNET-40333) have been fixed in this update.

@Orenk9,
RFC 3501 does not assume search by such attribute like the existence of attachments but Gmail has IMAP Extensions that allow implementing this search. With Aspose.Email 21.8, you can perform this search for Gmail as shown below:

ImapQueryBuilder builder = new ImapQueryBuilder();
builder.CustomSearch("X-GM-RAW \"has:attachment\"");
MailQuery query = builder.GetQuery();
messageInfoCol = client.ListMessages(query);

Documents and API Reference will be updated later.