send message

Giganews Newsgroups
Subject: send message
Posted by:  JP LIENARD (jpliena…@skynet.be)
Date: Fri, 27 May 2005

Hello,

Maybe asked 100 times...

When I send a message with one or more attachment, no problem.
When I send a message with no attachment, the body of the message is send as
2 .dot attachments and the body is empty...

I just install Indy 10

For info, all my indy files are dated 04/03/2005 19:55 but the
MailMessage.Version reports 8.0.25

iDVers.inc contains :
    gsIdProductName = 'Indy';
    gsIdVersion = '10.0.76';

Any idea welcome

Jean-Pierre Lienard
DataRag scrl, Belgium

my code :

  SMTP := TIdSMTP.Create(nil);
  MailMessage := tIdMessage.Create(nil);
  SMTP.Host := sSMTPhost;
  SMTP.Port := nSMTPport;

  if sCharset = '' then
    MailMessage.charset := 'us-ascii' // ISO-8859-1
  else
    MailMessage.charset := sCharset;

  //setup mail message
  MailMessage.From.Address := sMailBox; //'jpliena…@skynet.be';
  MailMessage.From.Name := sUserName;
  MailMessage.Recipients.EMailAddresses := sTo ;
  MailMessage.BccList.EMailAddresses := sCC;
  MailMessage.Subject := sSubject;
  MailMessage.Body.Text := slBody.Text; //  'The body';
  MailMessage.Body.Assign(slBody);

  for i := 0 to slAttach.Count - 1 do
  begin
    TIdAttachment.Create(MailMessage.MessageParts, slAttach[i]);
  end;

  MyResult := slBody.Text;
  //send mail
  try
    try
      SMTP.Connect;
      SMTP.Send(MailMessage);
    except on E: Exception do
      begin
        MyResult := 'ERROR: ' + E.Message;
      end;
    end;
  finally
    if SMTP.Connected then
      SMTP.Disconnect;
  end;

  SMTP.free;
  MailMessage.Free;

Replies