IMAP selection from the mime part without receiving the entire message

I need help creating an IMAP fetch command to get only a specific mime attachment without retrieving the whole body or another application. Given the following body structure

(BODYSTRUCTURE (("text" "html" ("charset" "utf-8") NIL NIL "base64" 568 8 NIL NIL NIL) "mixed" ("boundary" "===============0621936444==") NIL NIL))

What would the fetch command look like to extract the text / html part? I read section 6.4.5 of RFC3501 several times, but I still don't understand it. Any pointers to additional sample query requests for mime attachments will also be appreciated.

+3
source share
4 answers

On top of my head, it will be something like:

FETCH 88 BODY.PEEK[1]

where 88 is the 88th message, and 1 is the body part.

+6
source

Try the following:

FETCH uid BODY.PEEK[1.2]
+3
source

UID FETCH uid_of_the_mail BODY[1.2] . , gmail, 1 TEXT, 2-N . 1.1 TEXT, 1.2 , 1.N-1 N- .

+1

bodystructure, . , , .

, ,

. FETCH msgno (BODY [1.MIME])

-1

Source: https://habr.com/ru/post/1728442/


All Articles