Decoding Emails with Indy10

Giganews Newsgroups
Subject: Decoding Emails with Indy10
Posted by:  glup (
Date: Tue, 24 Feb 2004

My questions are related to decoding emails. I have looked into mailclient,
but still do not understand the following points

1. How do I get a Stream of a Message Part? I want to decode in _memory_ a
embedded message/rfc822 part.

2. How do I get the structure of the mail?
A really complex example message:

1            text/plain
2            application/octet-stream
3            message/rfc822
3.1            text/plain
3.2            application/octet-stream
4            multipart/mixed
4.1            image/gif
4.2            message/rfc822
4.2.1            text/plain
4.2.2            multipart/alternative              text/plain              text/richtext

I need to address parts by the numbers in the first column.
How to dive into the message/rfc822 parts should be answered with (1).

I have seen TIdMessagePart.ParentPart and imaginge to use it as follows but
would like to verify this:
* search in TIdMessage.MessageParts those parts with ParentPart = -1.
* For each of those Parts (lets name it CurPart) I search those in
TIdMessage.MessageParts where TIdMessagePart.ParentPart = CurPart.Index
* and repeat that recursivly until I found the requested part

3. How do I get these parts in a raw format (as TStrings) without anything
done regarding charset, encoding and other transformations.