IMAP getting UID List of selected folder

How can I get the IMAP UID list from the selected folder? I want to get a list of mail UIDs, so I pass 1150 UID FETCH FLAGS (\Seen \Flagged) , but I can not get the list: it gives me an error, for example BAD Command . So how can I get a list of UIDs from a selected folder?

+6
imap
source share
1 answer

The easiest (and most compact) way to list all the UIDs in the currently selected folder is through the UID SEARCH ALL :

 A001 UID SEARCH ALL * SEARCH 288 291 292 293 295 323 324 325 326 327 385 387 472 474 641 720 748 A001 OK UID SEARCH completed 

Errors in your UID FETCH request did not take into account the sequence set and included a list of flags. If you rewrote it as

 A002 UID FETCH 1:* (UID) 

or

 A002 UID FETCH 1:* (UID FLAGS) 

it will work.

+10
source share

All Articles