pysnake
pysnake

Reputation: 117

IMAP fetch of a mime part without fetching the whole message

I need some help formulating an IMAP fetch command to only fetch a certain mime attachment without fetching the whole body or other attachment. Given the following bodystructure

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

how would a fetch command for fetching the text/html part look like? I have read Section 6.4.5 of RFC3501 several times but I still don't get it. Any pointers to further examples of fetch requests for mime attachments would also be appreciated.

Upvotes: 3

Views: 7776

Answers (4)

Subbi Reddy K
Subbi Reddy K

Reputation: 412

First of all you need to parse bodystructure response and then find each part section string, Once you have acheived each part section string then You can fetch required part mime.

Assume that You need to fetch first part mime then command should be like this

. FETCH msgno (BODY[1.MIME])

Upvotes: -1

Nick Dong
Nick Dong

Reputation: 3736

UID FETCH uid_of_the_mail BODY[1.2] is the first inline attachment. Well, for gmail, 1 for TEXT, 2-N for attachment. 1.1 for TEXT, 1.2 should for the first inline attachment, 1.N-1 should for the Nth inline attachment.

Upvotes: 2

dave wanta
dave wanta

Reputation: 7214

Off the top of my head it would be something like:

FETCH 88 BODY.PEEK[1]

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

Upvotes: 6

jack-london
jack-london

Reputation: 1619

Try this one:

FETCH uid BODY.PEEK[1.2]

Upvotes: 3

Related Questions