Re: send emails - Invalid FLoating Point

Giganews Newsgroups
Subject: Re: send emails - Invalid FLoating Point
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Wed, 28 Nov 2007

"Nicolas Jardillier" <nicolas.jardilli…@keepcore.com> wrote in message
news:8ACDA0BFD33EE340nicolas.jardilli…@keepcore.com...

> Sometines i have this exception, when the program try to send
> an email: An exception has occurred : EInvalidOp=Invalid
> floating point operation

That is not enough information to diagnose your problem.  You did not show
what the actual values are that you are assigning to the components.  Have
you tried stepping through the code in the debugger yet to see where the
exception is actually occuring?

> anEmail.MailMessage.Body.Text := aBodyText

I assume you meant FMailMessage.Body instead?

Your code can be simplified to the following:

    try
        FMailMessage := TIdMessage.Create;
        try
            FMailMessage.From.Text := aFrom;
            FMailMessage.Sender.Text := aFrom;
            FMailMessage.Recipients.EMailAddresses := aTo;
            FMailMessage.Subject := aSubject;
            FMailMessage.Body.Text := aBodyText

            FSMTP := TIdSMTP.Create(nil);
            try
                FSMTP.Host := aHost;
                FSMTP.Port := aPort;
                FSMTP.Connect;
                try
                    FSMTP.Send(FMailMessage);
                finally
                    FSMTP.Disconnect;
                end;
            finally
                FSMTP.Free;
            end;
        finally
            FMailMessage.Free;
        end;
    except
        on E:Exception do
        begin
            // log the error as needed...
        end;
    end;

Gambit

Replies

In response to

send emails - Invalid FLoating Point posted by Nicolas Jardillier on Wed, 28 Nov 2007