0
votes

What is the difference between the fetch command and the search command in IMAP?

I am trying to get the messages in my inbox, I use the following command to retrieve the UID:

sb = receiveResponse("$ UID SEARCH ALL\r\n");

then I use this command to fetch a particular message header:

sb = receiveResponse("$ FETCH " + number+ " BODY.PEEK[HEADER.FIELDS (From Subject Date)]\r\n");

Does the fetch command use the UID to get the message header or does it use the message number?

If it uses the message number, how do I retrieve the message numbers?

2

2 Answers

2
votes

Use UID FETCH to fetch by uid. Use just FETCH to fetch by message sequence number.

1
votes

If you want to just download all messages in the INBOX folder, all you need to do is

FETCH 1:* BODY.PEEK[HEADER.FIELDS (From Subject Date)]