Using Indy 10.1.5 (the version shipped with D2007), I'm composing and sending an email message as part of an automated internal process.
The email is sent fine, but when the recipient receives the message the time appears incorrectly in the email client, causing the message to incorrectly sort in the inbox. This has caused the recipient to overlook the message (because it wasn't in the inbox in the proper sequence and scrolled off the bottom), causing minor processing delays.
Both the sender and recipient in the US Eastern time zone (UTC -0400). The message header is correctly showing the message date, but without including a time zone:
Date: Mon, 3 Aug 2015 11:12:21 +0000
When the email is received and viewed in Outlook, the message is being shown with the UTC offset:
Mon 08/03/2015 7:12 AM
The code that creates the message is pretty simple (copied/pasted and then anonymized and simplified). It creates a relatively short message body (providing info about the file attached), creates the attachment, and sends the message. (try..except
and try..finally
removed for brevity - they exist in the actual code.)
Msg := TIdMessage.Create;
// Also tried using False and setting Date property manually
Msg.UseNowForDate := True;
for i := 0 to NumAddr do // Number of recipients
begin
Msg.Recipients.Add;
Msg.Recipients[Msg.Recipients.Count - 1] := RecipAddr[i];
end;
Msg.FromList.Add;
Msg.FromList[0].Name := Sender Name;
Msg.FromList[0].Address := SenderAddress;
Msg.Subject := 'Some text';
Msg.Body.Add('A few lines of text providing summary info.');
TIdAttachmentFile.Create(Msg.MessageParts, FileToAttach);
Mail := TIdSMTP.Create;
Mail.Host := PrimaryMailServer;
Mail.Connect;
Mail.Send(Msg);
Mail.Disconnect;
I've read through the Indy documentation and examined all of the properties I can find for both TIdSMTP
and TIdMessage
, and can't find anything else that would correct this time zone mismatch.
Can anyone see what it is I'm missing here?