views:

430

answers:

1

Im writing a IMAP mail application running on J2ME. It's my senior project.

First, I would like to know that are there any IMAP messages to get the body of message only, not include an attachement?

When I send the message to IMAP Server like..

. fetch 20 body[text]

The IMAP Server will response like

<--BODY PART-->

---MOQ1233897306fd448beb67b3c728ca47f0f5c3dbef2f Content-Type: image/jpeg; name="card.jpg" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="card.jpg" /9j/4RPsRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAA ...

So, I have no idea how to get just the body not an attachment!? How do I know the file size and how many attached files in the message before load all these message and calculate for the file size?

If anyone knows about this, pls help me. Thank you a lot.

+1  A: 

You will have to ask the server for the BODYSTRUCTURE of that message:

FETCH 20 BODYSTRUCTURE

You will then have to parse the response and decide about the presence of absence of attachments. Here's a sample response of a message with a plain-text part and three attached images:

20 FETCH (BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "ISO-8859-15" "FORMAT" "flowed") NIL NIL "8BIT" 950 30 NIL NIL NIL)("IMAGE" "JPEG" ("NAME" "r001-023.jpg") NIL NIL "BASE64" 1708116 NIL ("INLINE" ("FILENAME" "r001-023.jpg")) NIL)("IMAGE" "JPEG" ("NAME" "r001-022.jpg") NIL NIL "BASE64" 2077114 NIL ("INLINE" ("FILENAME" "r001-022.jpg")) NIL)("IMAGE" "JPEG" ("NAME" "r001-012.jpg") NIL NIL "BASE64" 2374832 NIL ("INLINE" ("FILENAME" "r001-012.jpg")) NIL) "MIXED" ("BOUNDARY" "------------090105040606010906000608") NIL NIL))
innaM