Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Send mail silently

edited June 2006 in General
Hi,

In my app I want send report silently with TppReport.SendMail.

I have registered Indy: TppSMTPPlugIn.RegisterClass(TppSMTPIndy) and
defined all values for TppReport.EmailSettings. It works fine if all values
of TppReport.EmailSettings are correct. But if some values are not correct
(e.g. password), then I have no feedback in run time. I would have wished
myself an exception or a return value from the TppReport.SendMail function.
Can I experience somehow whether Mail was really sent?



Regards

Marek

Comments

  • edited June 2006
    Hi Marek,

    Thank you for pointing this out. We will add event support to expose the
    status of the email message for a later release of ReportBuilder.
    Unfortunately to do this, the email source files cannot be interface
    compatable so a patch is not possible at this time. In the mean time you
    could very easily make a quick change to the ppSMTPIndy.pas source to expose
    the Indy error exception messages. Something like this would give you what
    you are after...

    File: ppSMTPIndy.pas

    {------------------------------------------------------------------------------}
    { TppSMTPIndy.Connect }

    function TppSMTPIndy.Connect: Boolean;
    begin

    if not FSMTP.Connected then
    begin
    FSMTP.Host := Host;

    {$IFDEF Delphi7}
    FSMTP.UserName := UserID;
    {$ELSE}
    FSMTP.UserId := UserID;
    {$ENDIF}

    FSMTP.Password := Password;
    FSMTP.Connect;
    end;

    //begin changed code......
    try
    Result := FSMTP.Connected and FSMTP.Authenticate;
    except
    ShowMessage(FSMTP.LastCmdResult.Text.Text);
    end;
    //end changed code.......

    end; {function, Connect}

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2006
    Hi Nico,

    thanks for your answer.
    Please do not use ShowMessage in your update in the future.
    I strike before following changes, that I made.

    function TppSMTPIndy.Connect: Boolean;
    ......
    try
    Result := FSMTP.Connected and FSMTP.Authenticate;
    except
    raise Exception.CreateFmt('Can not connect to mail server %s for user
    %s',[Host,UserID ]);
    end;

    procedure TppEmail.Send;
    .......
    except
    raise; //added
    end;

    Best regards
    Marek

  • edited June 2006
    Hi Marek,


    Yes, this was just an example to lead you in the right direction. The code
    I posted will not be added into ReportBuilder.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.