Indy 9.03B
Delphi 6
I could not find the ftp location for the latest Indy files so I don't know
if this has been fixed and the bug list does not appear to report this
particular bug. So I am submitting it, just in case.
If I missed something else entirely, I would appreciate a pointer.
Bug description:
================
The headers are correctly generated and sent with the SMTP client, but they
are not retained in the Headers property of the message.
To reproduce:
=============
1 - In the MailClient2 project of the demos, edit the file MsgEditor.
2 - In procedure TfrmMsgEditor.btnOkClick, locate the line
SMTP.Send(IdMsgSend). It's the fifth line from the end of the procedure.
3 - Below SMTP.Send(IdMsgSend), add the following line:
frmMain.IMAP.AppendMsg('YourMailBox', IdMsgSend, [mfRecent, mfSeen])
4 - Compile, run, login, try sending a message.
5 - In 'YourMailBox' you will find a new message, with no headers but the
body text is Ok. On the other hand the sent message will have all the
appropriate headers.
Note that you probably don't have to go through all this. Just stop the
program after the SMTP.Send and examine the Headers property of IdMsgSend.
Tentative fix:
==============
I believe the bug is in TIdMessage.GenerateHeader: TIdHeadersList. I suggest
the fix below:
InitializeISO(TransferHeader, HeaderEncoding, ISOCharSet);
DoInitializeISO(TransferHeader, HeaderEncoding, ISOCharSet);//APR
{Commented out by PClri 2002-Jan-30
Result := TIdHeaderList.Create;
// added 2001-Oct-29 Don Siders insures use of headers received but not
used in properties
if (FHeaders.Count > 0) then begin
Result.Assign(FHeaders);
end;
}
try
{Commented out by PClri 2002-Jan-30
with Result do
}
{ Added by PClri 2002-Jan-30 }
with FHeaders do
{ End add 2002-Jan-30}
begin
.
.
.
// Add extra headers created by UA - allows duplicates
if (FExtraHeaders.Count > 0) then
begin
AddStrings(FExtraHeaders);
end;
end;
{ Added by PClri 2002-Jan-30 }
// Calling routines expect something to delete so let us give it to them
Result := TIdHeaderList.Create;
Result.Assign(FHeaders);
{ End add 2002-Jan-30}
except
FreeAndNil(Result);
{ Added by PClri 2002-Jan-30 }
FHeaders.Clear;
{ End add 2002-Jan-30}
raise;
end;
6 - Rationale:
==============
Since FHeaders is already initialized when IdMessage is created why not just
use it as is. But since at least one calling routine expects something
they're going to delete, I let it have it by copying FHeaders to Result.
Best regards,
Philippe Clri (phili...@gcal.net)