Send mail silently
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
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
This discussion has been closed.
Comments
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
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
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
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
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com