Once you have the headers for a particular folder, you'll
be using "tny_folder_get_msg_async" to get a TnyMsg, one
for each TnyHeader.
For each TnyMsg you receive in your callback function, you
tnen use "tny_mime_part_get_parts" on the TnyMsg - it will
give you back a list of mime parts for that TnyMsg that you
can iterate through - and for each mime part in that list,
you can query its type (using "tny_mime_part_content_type_is") -
and look for the mime parts you are interested in.
In my case, I was mostly interested in the main text body of
an email message, so once I found a "text'plain" type , I then
used "tny_mime_part_decode_to_stream_async" to get the main
text body. Then you can use "tny_stream_read" in your callback
function to extract out the actual bytes of the message text -
and don't forget to call "tny_stream_reset" BEFORE you run off
and use "tny_stream_read" (I see this as a bug in their library,
since the caller of your callback should make sure the stream
they provide you has been reset back to the start of the stream!).
Also, one IMPORTANT note about the list of mime parts that you
get back from "tny_mime_part_get_parts" - if the list you get
back from this call is empty (a NULL iterator), then this does
NOT mean you have an empty message - it means that the TnyMsg IS
the one and only mime part - so use "tny_mime_part_content_type_is"
on the TnyMsg to determine the type of message. This bug (even
though the developers insisted it was meant to work this way)
really threw me for a loop initially - I was getting headers for
all my messages, but every message I had in my test folder were
simple messages (just one mime part - "text/plain") - so I was
confused because it looked like I was unable to get the main message
bodies for any of my messages! IMHO, the "tny_mime_part_get_parts"
method should return a list of size 1, when there is just one mime
part. This way, you have a very simple loop that iterates through
all the mime parts - even when there is only 1 mime part! Oh, well...
Hope this helps you!
- Steve Rosen
evolution test wrote: