Sending email with MSExchange 5.5

Giganews Newsgroups
Subject: Sending email with MSExchange 5.5
Posted by:  Joe Reiss (medida…@ix.netcom.com)
Date: Tue, 15 Jul 2003

Using Delphi 5 enterprise
Indy 8.0.22

I'm trying to send email from my app using IdSMTP1 component.

The Exchange server has SMTP enabled or so I'm told.

Can't get it to work.  I suspect I need to set authentication to
saUserNamePassword to login into Exchange server.  If this is the case how
can I programmaticaly get the username and password to give to the
component?

My code:

try
    idMsg := TIdMessage.Create(nil);
      try
        with idMsg do
        begin
          From.Address          := sEmailFromAddress;
          Recipients.Add.Address := sEmailAddress;
          Subject                := sSubject;
          Body.Text              := slBody.Text;
        end;
        IdSMTP1.Host := sEmailHost;
        IdSMTP1.Connect;
        result := FUNC_PASS;
        try
          IdSMTP1.Send(idMsg);
        finally
          IdSMTP1.Disconnect;
        end;
      finally
        idMsg.Free;
      end;
  except
    on e:exception do
      begin
        alAppLog.bWriteToErrorLog (UNIT_NAME + '.iSendEmail', e.message);
        result := FUNC_FAIL;
      end;
  end;

Thanks,
Joe

Replies