We have an app that (using the GWOAPI) gets messages from GW to archive
and replace the original message with a version which (e.g.) has some
Attachments removed/ added. Which works fine as such.
As well as when the message processed has one or more attached messages,
which then are processed recursively.

The procedure is (or let's say should be) as follows:

[1] Iterate over mail attachments
[2] if attachment is an "email" start with the mai-object at [1]
(when execution returns go ahead with the next attachment or [3])
[3] Create new draft-message
[4] Add all (wanted) attachments of original message them to the draft
[5] Create new Message by calling AddExistingMessage() of the messages
collection of the destination folder giving the draft-message.
[6] Delete the original message
[7] return

We use a custom Model-API on top of GWOAPI to connect it to our
logic-layer. So that on [2], if the attachment is an message and it is
replaced with a new message (in GW) the changes (to MessageID, etc.) are
transparent to the calling method.

Let's say we have an email "mail-three" and this email has an attached
email "mail-two" which in turn has an attached email "mail-one".

So, mail-one is the first to be "re-created" and when we are at [3] with
mail-three, the others (mail-one and mail-two) both have been processed
(/ replaced) completely yet, so that mail-one's references (MessageIDs
of attachments, etc.) should be "fine" - I would have thougt. :)

But, unfortunately, this does not seem to be the case. Because when the
"message-depth" is greater than two (as in the above example with three)
you get the error message d107, when trying to open the email
(mail-three) in GW-client, saying that the entry was not found
("Datensatz nicht gefunden") and that one should consult the admin.

I assume that there is an error in my reasoning and it's not applicable
to just add messages to Attachments collections as "needed"?

As it is, we can't switch from the recursive manner - or at least not in
a cheap way - so my questions are:
- Am I missing something?
- Does someone know a way to achive what the above example does?

Thanks a lot in advance!

Best regards,
Gabriel Jost