Re: TIdMessage.Headers empty

Giganews Newsgroups
Subject: Re: TIdMessage.Headers empty
Posted by:  Remy Lebeau \(TeamB\) (no.spam@no.spam.com)
Date: Thu, 31 Jul 2008

"Philip von Melle" <philip.vonmel…@globetrotter.de> wrote in message
news:Xns9AECE8B0534DEphilipvonmelleglo…@87.106.16.84...

> I have created an instance of TIdMessage and set the Subject,
> From and Recipient properties as well as the body. But when
> accessing AMsg.Headers.Text it is empty.

As it should be.  Those properties do not use the Headers property for
storage.  In fact, the Headers property is only filled in when loading a
message from file/stream, or receiving it over a connection.

> When using AMsg.SaveToFile all headers appear correctly
> (as well as the body).

Saving the message to file/stream invokes the same logic that is used when
transmitting the message over the connection.  Any Headers values that may
be present are copied to an internal TIdHeaderList (the LastGeneratedHeaders
property), and then the various TIdMessage properties overwrite those values
as needed.  That TIdHeaderList, not the original Headers, is then used when
formatting the message data.

> What do I need to do to get the Headers property filled
> appropriately?

You don't.  That is not how TIdMessage works.

Gambit

Replies

In response to

TIdMessage.Headers empty posted by Philip von Melle on Thu, 31 Jul 2008