Re: MIME problems with TIdSMPTServer -> File -> TIdSMTP -> Exchange Server

Giganews Newsgroups
Subject: Re: MIME problems with TIdSMPTServer -> File -> TIdSMTP -> Exchange Server
Posted by:  Remy Lebeau (Indy Team) (
Date: Tue, 6 Mar 2007

"Nicholas Ring" <Nicholas.Ri…> wrote in message

> The problem I am having is with MIME encoded emails... The
> message body doesn't seem to make it to the server.

Since you are using Indy 9, I strongly suggest that you disable
TIdSMTPServer's and TIdMessage's ability to parse the received data.
You are not doing that right now.  This way, you can save the data to
file exactly as it was received from the client, and there is no
possibility for Indy to alter/corrupt the data.  The way you have it
right now, TIdMessage is parsing and then regenerating the data anew.
Indy 9 does not handle MIME-encoded messages very well, especially if
there are nested parts in the message.

> I get:
> And not
> As I would expect.

Since you did not show what the original messages look like to begin
with, there is no way to say whether you are actually getting what is
expected or not.

> What am I doing wrong with MIME encoding?

You are letting Indy parse the data.

> IdSmtpServer.NoDecode              := True;
> IdSmtpServer.ReceiveMode            := rmMessageParsed;

I would suggest setting ReceiveMode to rmRaw and use the OnReceiveRaw
event instead.

> --- Resender Start ---
> IdMessage := TIdMessage.Create(nil);
> IdMessage.LoadFromFile(DirEmail + SearchRec.Name);

You are not setting the NoDecode and NoEncode properties, so
TIdMessage is going to parse and re-generate the file data into its
own formatting.  That can be very error-prone, depending on the
complexity of the message content.  I strongly suggest that you set
both NoDecode and NoEncode to True so that the file can be sent to the
Exchange server exactly as it was saved without any extra processing.



In response to

MIME problems with TIdSMPTServer -> File -> TIdSMTP -> Exchange Server posted by Nicholas Ring on Wed, 7 Mar 2007