While trying to transfer an Imap TIdMessage from a Thread to the MainThread, I discovered that saving it to Stream and then loading it back does not work.
Log('Msg.MessageParts.Count='+Msg.MessageParts.Count.ToString,d_4); // 3 parts
AStream := TMemoryStream.Create;
MSG.SaveToStream(AStream);
MSG := TIdMessage.Create(nil);
MSG.LoadFromStream(ASTream);
Log('After Load: Msg.MessageParts.Count='+Msg.MessageParts.Count.ToString,d_4);// Zero parts
Is there something I can do about this? I need a copy of the entire TIdMessage.
AStream.Position
back to0
before callingMsg.LoadFromStream()
? Also, why not just transfer the wholeTIdMessage
object as-is instead of a copy of its data viaTMemoryStream
?