automatically send email after print
Hi!
I want, with RAP, automatically send an mail after the report is
printed or , better, previewed at screen.
All email setting are correctly setted.
I add a onAfterPrint event in RAP and call report.sendmail. It works,
but it call the sendmail twice. outlook appears 2 times...
i tried other events, with the same issue.
i suppose the first call to sendmail re-call the same event...
there's a property set in report when i call "sendmail" so i can manage
it and undertand what's the output in this moment ?
thanks
I want, with RAP, automatically send an mail after the report is
printed or , better, previewed at screen.
All email setting are correctly setted.
I add a onAfterPrint event in RAP and call report.sendmail. It works,
but it call the sendmail twice. outlook appears 2 times...
i tried other events, with the same issue.
i suppose the first call to sendmail re-call the same event...
there's a property set in report when i call "sendmail" so i can manage
it and undertand what's the output in this moment ?
thanks
This discussion has been closed.
Comments
In my quick testing with a simple app, the OnAfterPrint is only fired
once (therefor sending only one email) when previewing the report.
Note that the AfterPrint is only called once the Preview Window is
closed or after the report has been successfully printed to the printer.
My suggestion would be to get this working in Delphi first so you can
trace your event code and see exactly what is happening. Then move the
code to RAP knowing that it works properly in Delphi.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
with this :
procedure reportAfterPrint ;
begin
showmessage(Report.DeviceType);
end;
message is shown only 1 time.
but with
procedure reportAfterPrint ;
begin
showmessage(Report.DeviceType);
REPORT.sendmail ;
end;
i have a message, then outlook starts, then another message and outlook
restart.....
Sembra che Nico Cizik (Digital Metaphors) abbia detto :
Thanks, I now understand what is happening. Calling Report.SendMail
will generate a report to file and execute the AfterPrint again and
again in an endless loop.
One way to work around this is to create a global boolean variable that
switches off once the email has been sent.
For instance, inside the Report.OnInitializeParameters you could set it
to True.
procedure ReportOnInitializeParameters(var Cancel: Boolean);
begin
FEmail := True;
end;
Then in the AfterPrint check for True and toggle.
procedure ReportAfterPrint;
begin
if FEmail then
begin
FEmail := False;
Report.SendMail;
end;
end;
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com