“Is is possible to automatically email each group to a separate recipient?”
Starting with ReportBuilder 12, the Email Groups feature was added allowing a user to automatically export and send each group in a report to a separate recipient. Below are steps for utilizing this feature.
1. First create a report and open the groups dialog by selecting the Report | Groups main menu option.
2. Create a new group and select the option to “Email Group”. Now when you export this report (via printing) you will export and send each group as a separate file.
3. Now that we are going to email each group, we need to set up the email settings for each file being sent. This can be done in two ways: using the Group.OnGetEmailSettings event or using the Group.GroupFileSettings.EmailField property. The EmailField property can be set to a datafield in the connected dataset containing the email address(s) for each recipient. If the email addresses are elsewhere manual control over the EmailSettings for each report can be taken by implementing the OnGetEmailSettings event in Delphi or RAP. This event passes the TppEmailSettings object that will be used for the specific group report being sent. Use the TppEmailSettings properties to customize the email for each recipient.
4. Finally export the report as you would normally by selecting the print button and choosing to Print To File from the print dialog or printing manually in code.
– Emailing groups is not supported from the email button in the Preview or from the TppEmail object (Report.SendMail).
– It is highly recommended that you use direct-connect email plugin such as Indy or Synapse to email groups.
Sample Delphi code:
procedure TForm1.Button2Click(Sender: TObject);
FEmailPos := 0;
ppReport1.AllowPrintToFile := True;
ppReport1.DeviceType := 'PDF';
FEmailList := TStringList.Create;
procedure TForm1.FormCreate(Sender: TObject);
ppReport1.EmailSettings.HostAddress := '';
ppReport1.EmailSettings.UserName := '';
ppReport1.EmailSettings.Password := '';
ppReport1.TextFileName := ExtractFilePath(Application.ExeName) + 'Invoice.pdf';
procedure TForm1.ppGroup1GetEmailSettings(Sender, aEmailSettings: TObject);
lEmailSettings := TppEmailSettings(aEmailSettings);
lEmailSettings.EmailSettings.Body.Text := 'Pay up!!';