I would like to retrieve the header text from a POP3 message into a TMemo. I cannot figure out how to do this. Here’s what I’ve got so far:
try
IdPOP31.Connect();
MsgCount := IdPOP31.CheckMessages;
for i:= 1 to MsgCount do
begin
try
FMailMessage := TIdMessage.Create(nil);
IdPOP31.Retrieve(i,FMailMessage);
Memo1.Lines.Add('Mesage #: ' + IntToStr(i);
Memo1.Lines.Add('From name: ' + FMailMessage.From.Name);
Memo1.Lines.Add('From address: ' + FMailMessage.Sender.Address);
Memo1.Lines.Add('Subject: ' + FMailMessage.Subject);
Memo1.Lines.Add('From:' + FMailMessage.From.Address);
Memo1.Lines.Add('Recipients: ' + FMailMessage.Recipients.EMailAddresses);
// HOW DO I GET THE HEADER ???????
Memo1.Lines.Add(FMailMessage.Body.Text);
Memo1.Lines.Add('=================================================');
finally
FMailMessage.Free;
end;
IdPOP31.Disconnect;
end;
You can use the
Headersproperty of the message, which is aTStringListdescendant. So to add header values for the message to your memo you can use one of the following statements: