Please clarify do you compose a message using TElMessage class, or do you parse a message from a stream/file?
If you create a new message, do you need the entire header before the message is assembled an written to a stream?
If you parse a message from a stream, you can use GetHeaderFromStream function which can be found in the SBMIME unit.

If you compose a message to a stream before sending, you can use the mentioned function GetHeaderFromStream from the SBMIME unit. Just rewind the stream and use the function.
If you send a message using our SMTP component, then you can try to use TElMessage.MainPart.Header.Assemble method.
But it's better to use the first way. Using the first way, you'll be sure you have the same header as the one was sent. Using the second way, you will assemble the header again and result may be different from the data sent to the recipient.

As soon as you need to store the header for historical purposes only, I'd suggest to use the following way:
1. Assemble a newly created message using TElMessage.Assemble method to a temorary (memory of file depending on the message size) stream;
2. Use TElSMTPClient.Send(const MailFrom: string; RcptTo: TStringList; Message: TStream) method to send the assembled message;
3. Rewind the stream using Stream.Position := 0;
4. Use GetHeaderFromStream function to obtain the sent header.

Later we'll add a new Send method which will accept only a message stream, without two first parameters.

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.