The built-in email feature provides numerous ways to export and send a report via email in a single step. Below is a description of how this can be done.
Send an email from the Preview Window:
Send an email in code from the Report:
Export and Send multiple reports at once:
Download: EmailExample.zip
Sample Delphi code:
Send an email from the preview window:procedure TEmailFrm.btnPreviewClick(Sender: TObject); begin //Register MAPI plugin... TppSMTPPlugIn.RegisterClass(TppSMTPMapi); ppReport1.EmailSettings.ShowEmailDialog := False; ppReport1.EmailSettings.PreviewInEmailClient := True; ppReport1.EmailSettings.Enabled := True; ppReport1.Print; end;Send an email from the report:
procedure TEmailFrm.btnMAPIClick(Sender: TObject); begin //Register MAPI plugin... TppSMTPPlugIn.RegisterClass(TppSMTPMapi); ppReport1.EmailSettings.ShowEmailDialog := False; ppReport1.EmailSettings.PreviewInEmailClient := True; ppReport1.EmailSettings.Body.Text := cMapiMail; ppReport1.SendMail; end;Send multiple emails using the TppEmail object:
procedure TEmailFrm.btnSendEmail(Sender: TObject);
var
lEmail: TppEmail;
begin
//Register MAPI plugin...
TppSMTPPlugIn.RegisterClass(TppSMTPMapi);
lEmail := TppEmail.Create;
try
ppReport1.EmailSettings.ShowEmailDialog := False;
ppReport1.EmailSettings.PreviewInEmailClient := True;
ppReport1.EmailSettings.Body.Text := cMapiMail;
//Add reports
lEmail.AddReport(ppReport1);
lEmail.AddReport(ppReport2);
lEmail.AddReport(ppReport3);
lEmail.Send;
finally
lEmail.Free;
end;
end;