|Subject:||TidMessage completely incompatible with outlook express?|
|Posted by:||Marco Caspers (HexorHax…@Vaxor.com)|
|Date:||Sun, 1 Jan 2006|
It's been a long time since i worked with Indy so i'm largely out of
the loop as to what's new Indy in version 10.
Having worked with Delphi 2006 for a few weeks now i decided to
investigate Indy again for a new project i'm starting up, i started
with the IndySMTP server demo.
It's a simple enough demo that works fine if you send a message to it
When i used outlook express to send a message to the Indy SMTP server
demo, the email was received correctly, the resulting .eml file
contains the full correct message.
Unfortunately though it seems that TIdMessage.LoadFromFile() and
TIdMessage.LoadFromStream() are both uncapable of reading the message
that was sent with outlook express either directly reading it from the
stream or loading from the .eml file.
The resulting TIdMessage is just completely empty.
Having read that TIdMessage is incompatible with .rtf i tried again
forcing outlook express to plain text model.
Unfortunately this didn't change a thing, TIdMessage was still empty.
My first reaction was to go to the Indy website and see if there was a
newer version available.
But apparently the Indy website hasn't been updated for a while as the
snapshot that was available for download seems (much) older than the
version in Delphi 2006 (10.0.52 versus 10.1.5).
I tried some of the links to development snapshots (a http mirror
actually), but at the moment it seems that that mirrored development
snapshot doesn't even support Delphi 2006, even though the IdVers.inc
has the same version number 10.1.5.
So my main question is:
Does anyone have a solution to the issue where TIdMessage is
of loading/reading messages that where sent with Outlook Express.
(Of course i can write my own parser for the resulting .eml file, but
i'd rather use TIdMessage if at all possible).
While i can dictate users to send e-mail in plain text format, i can
not controll the mailclient that they use, so outlook express support
is a must. Without that i must either write my own parser or switch to
another suite of components, which i'd rather not as i'm kind of
familiar with Indy.
A few other questions i have are:
- What is the VForward var parameter used for in the RcptTo event
RcptTo(ASender: TIdSMTPServerContext; const AAddress: string;
var VAction: TIdRCPToReply; var VForward: String);
- Is RcptTo triggered once for each recipient, or for all
recipients at once?
- What is the LAction TidDataReply used for in the MsgReceive event
MsgReceive(ASender: TIdSMTPServerContext; AMsg: TStream;
var LAction: TIdDataReply);
(Yes i've checked the documentation, but the information in there
doesn't tell me what i'm asking).
Demo code used to load message:
(Yes i am aware of the dangers of threaded applications and directly
accessing vcl components, but for testing/demo purposes it suits me
fine as i'm the only one accessing the demo server anyways).
procedure TForm1.IdSMTPServer1MsgReceive(ASender: TIdSMTPServerContext;
AMsg: TStream; var LAction: TIdDataReply);
LMsg : TIdMessage;
LStream : TFileStream;
// When a message is received by the server, this event fires.
// The message data is made available in the AMsg : TStream.
// In this example, we will save it to a temporary file, and the load
// IdMessage and parse some header elements.
LStream := TFileStream.Create(ExtractFilePath(Application.exename) +
LMsg := TIdMessage.Create;
LMsg.LoadFromFile(ExtractFilePath(Application.exename) + 'test.eml',
ToLabel.Caption := LMsg.Recipients.EMailAddresses;
FromLabel.Caption := LMsg.From.Text;
SubjectLabel.Caption := LMsg.Subject;
Memo1.Lines := LMsg.Body;