SMTP mail server not forwarding attachment to recipients if more than one

Giganews Newsgroups
Subject: SMTP mail server not forwarding attachment to recipients if more than one
Posted by:  Codeman II (thegentlem…@webmail.co.za)
Date: Tue, 10 Jan 2006

Hi friends,

I am using Indy 9 (latest version) with Delphi 7.

I have an SMTP server application that receives all outgoing emails and log
them in a database whereafter I sent the
message to its destination(s).

Everything is working fine but when I include more than one email address in
the To: field of my email client, only the
first email are sent WITH the attachments (when attachments have been
added). All the rest of the emails are sent with the subject and body text
but no attachments. For example if I sent an email with attachments to:
1…@mail.com;2…@mail.com;3…@mail.com the 1…@mail.com email address
receives the
email with it attachments but the other email address' receive the email but
without any attachments.

I am using the idSMTPServer component and here is my code for the
OnReceiveMessageParsed event:
-----------CODE BEGIN--------------
var
  X, MailOutID :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!

  OkSave := True;

  Try
    lblTo.Caption := AMsg.Recipients.EMailAddresses;
    lblFrom.Caption := AMsg.From.Text;
    lblSubject.Caption := AMsg.Subject;
    memBody.Clear;

    AMsg.MessageParts.CountParts;
    If AMsg.MessageParts.TextPartCount > 0 then
      memBody.Lines.Add(TIdText(AMsg.MessageParts.Items[1]).Body.Text)
    Else
      memBody.Lines := AMsg.Body;

    // Implement your file system here :)
    idSMTP.Host := 'smtp.saix.net';
    idSMTP.Port := 25;
    idSMTP.Connect;

    Try
      idSMTP.Send(AMsg);
    Finally
      idSMTP.Disconnect;
    end;
  Except
    MessageDLG('An error occurred: ' + IntToStr(GetLastError) + '.',
mtError, [mbOk], 0);
    OkSave := False;
  end;
end;
-----------CODE END  --------------

Please advice.

Replies