Buggy TIdMessageDecoderMIME or just abusing it...

Giganews Newsgroups
Subject: Buggy TIdMessageDecoderMIME or just abusing it...
Posted by:  Andre Pietsch (sal…@scaiooopppqqq.de)
Date: Mon, 4 Aug 2003

Hi!

I have a problem with TIdMessageDecoderMIME in Indy 9.0.14. In
TIdMessageDecoderMIME.ReadBody there is a line
    if MIMEBoundary <> '' then begin

I don't know what it does I only know the following.

When using TidSMTPServer with NoDecode = false and ReceiveMode =
rmMessageParsed this line prevents it from processing text only mails
forwarded by MS Exchange.

With this line it does process HTML mails correctly but fails on the former.

Ass said above I do not know what this line is for, tested it a bit,
considered it useless and simply commented it out.

This is sufficient for testing but not for productive use.

==> Could someone please elaborate what this line is for and why it would
hurt to comment it out?

I'm quite sure that it is bug though any hint would be appreciated pointing
me in any direction helping me doing what I want:
Processing any email coming in with as simple code as I have now.

Here is how I do it based on the SMTPServer_demo from the Indy demo's:

procedure TForm1.IdSMTPServer1ReceiveMessageParsed(ASender: TIdCommand;
  var AMsg: TIdMessage; RCPT: TIdEMailAddressList;
  var CustomError: String);
  var intIndex : Integer;
begin
// This is the main event if you have opted to have the idSMTPServer to do
your parsing for you.
// The AMessage contains the completed TIdMessage.
// NOTE: Dont forget to add IdMessage to your USES clause!

  ToLabel.Caption := 'unset';
  FromLabel.Caption := 'unset';
  SubjectLabel.Caption := 'unset';
  Memo1.Lines.Clear;

  ToLabel.Caption := AMsg.Recipients.EMailAddresses;
  FromLabel.Caption := AMsg.From.Text;
  SubjectLabel.Caption := AMsg.Subject;
  // Implement your file system here :)

  if AMsg.MessageParts.Count > 0 then
    begin
      for intIndex := 0 to AMsg.MessageParts.Count - 1 do
        begin
          if (AMsg.MessageParts.Items[intIndex] is TIdAttachment) then
              begin //general attachment
                // Currently I ignore these
                // li := lvMessageParts.Items.Add;
                // li.ImageIndex := 8;
                // li.Caption :=
TIdAttachment(Msg.MessageParts.Items[intIndex]).Filename;
                //
li.SubItems.Add(TIdAttachment(Msg.MessageParts.Items[intIndex]).ContentType)
;
              end
          else
              begin //body text
                if AMsg.MessageParts.Items[intIndex] is TIdText then
                    begin
                      Memo1.Lines.Clear;

Memo1.Lines.AddStrings(TIdText(AMsg.MessageParts.Items[intIndex]).Body);
                    end
              end;
        end;
    end
  else
    begin
      Memo1.Lines.Clear;
      Memo1.Lines.AddStrings(AMsg.Body);
    end;
end;

==> All comments on this are highly appreciated.

Thx!

Regards
Andre, SCAI

Replies