1. Home
  2. /
  3. Docs
  4. /
  5. Articles Report Writer
  6. /
  7. Report Components
  8. /
  9. Page by Page

Page by Page

Page by Page emailing allows you to send individual pages of a report to different email addresses automatically during report generation. Each page is packaged as an attachment and sent to the recipient defined for that page.

Setting Up the Report Type

Every report that uses Page by Page emailing requires a ReportType component. If your report does not already have one, drop a ReportType component onto any band in the report designer.

Set the following properties on the ReportType component:

  • ReportKind — set to rtPageByPage
  • DefaultEmailSubject — the default subject line for all emails. Individual pages can override this.
  • DefaultEmailBody — the default body text for all emails. Individual pages can override this.
  • DefaultExport — the file format the attachment will be exported to, for example PDF or XLSX.
  • ExportSettings — optional. Click the Export Settings button on the Page by Page send form to configure and save export options specific to the chosen format.

Report Layout Requirements

For Page by Page emailing to work correctly, each recipient’s content must occupy its own page. The recommended layout is:

  • A GroupHeader band with StartNewPage set to True. This forces each group to begin on a fresh page, keeping each email attachment separate.
  • A MasterData band inside the group containing the report detail rows.

Without the GroupHeader forcing a new page, multiple recipients’ data could end up on the same page and be sent together in the wrong email.

Adding the PagebyPage Component

Drop a PagebyPage component onto the band you want to trigger email sending. This is usually the MasterData band or the GroupHeader band. The component is invisible in the printed report — it only runs logic during generation.

Set the following properties on the PagebyPage component:

  • EmailAddress — the recipient email address for this page. Required.
  • EmailName — the recipient display name.
  • EmailSubject — the subject line for this page. If left blank the ReportType DefaultEmailSubject is used.
  • EmailBody — the body text for this page. If left blank the ReportType DefaultEmailBody is used.
  • EmailAttachmentName — the filename used for the email attachment, without extension. For example Invoice_2024 becomes Invoice_2024.pdf.
  • EmailSend — set to True to include this page in the send queue. Default is True.

Using Expressions in Properties

All text properties on the PagebyPage component support Articles expressions, allowing you to pull live data from your dataset into the email properties.

A single field reference â€” type the field expression directly:

<fdquery1."Email_Address">

A single field for the attachment name:

<fdquery1."InvoiceNumber">

Mixing static text with a field â€” use expression syntax with quoted text and the + operator:

'Invoice for ' + <fdquery1."CompanyName">

Multiple fields combined:

<fdquery1."FirstName"> + ' ' + <fdquery1."LastName">

Building an attachment filename from data:

'Invoice_' + <fdquery1."InvoiceNumber">

Using a calculation in the subject:

'Your statement for ' + <fdquery1."PeriodName"> + ' is ready'

Note: If your static text contains the characters < or > you must wrap them in quoted strings using the + operator, otherwise Articles will attempt to evaluate them as an expression and an error will occur. For example, to include a literal > in your subject line:

'Amount ' + '>' + ' 0 — please review ' + <fdquery1."CompanyName">

Sending to Multiple Recipients Per Page

You can drop more than one PagebyPage component onto the same band. Each component is processed independently, so the same page can be sent to multiple addresses. Common uses:

  • Send each invoice to the customer and a hardcoded accounts address.

First component — customer copy:

EmailAddress:        <fdquery1."Email_Address">
EmailSubject:        'Your invoice from Acme Ltd'
EmailAttachmentName: 'Invoice_' + <fdquery1."InvoiceNumber">

Second component — internal copy:

EmailAddress:        accounts@acme.com
EmailSubject:        'Customer invoice copy — ' + <fdquery1."CompanyName">
EmailAttachmentName: 'InternalCopy_' + <fdquery1."InvoiceNumber">

Using the Report Script for Advanced Control

For situations where you need more control over which emails are queued, Articles exposes two script functions you can call directly from the report script.

PagebyPageEmailClear

PagebyPageEmailClear() clears all emails that have been queued so far. This is useful when you need to reset the email list part way through a report, for example to exclude certain records based on a condition.

The most common place to call it is in the OnStartReport event, which guarantees the queue starts empty at the beginning of every run:

procedure ReportOnStartReport(Sender: TfrxComponent);
begin
  PagebyPageEmailClear();
end;

It can be called from any event in the script, not just OnStartReport.

PagebyPageEmailAdd

PagebyPageEmailAdd lets you add an email entry to the queue directly from script, giving you full programmatic control over every parameter. Use this when conditions in the data determine whether an email should be queued, or when you need logic that the PagebyPage component properties alone cannot express.

The function signature is:

procedure PagebyPageEmailAdd(
  EmailAddress    : String;
  EmailName       : String;
  Subject         : String;
  Body            : String;
  AttachmentName  : String;
  SSendEmail      : Boolean;
  PageNumber      : Integer
);

The most common place to call it is in the OnBeforePrint event of the band you are grouping by. This example queues an invoice email for each master data row:

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
  PagebyPageEmailAdd(
    <Header."email_Address">,
    <Header."CompanyName">,
    'Invoice for ' + <Header."Reference">,
    'This is the email body',
    'Invoice',
    True,
    <Page>
  );
end;

Parameter notes:

  • EmailAddress — recipient email address. Can be a field expression or a hardcoded string.
  • EmailName — recipient display name.
  • Subject — email subject. Supports concatenation of static text and field expressions as shown above.
  • Body — email body text.
  • AttachmentName — attachment filename without extension.
  • SSendEmail — pass True to include in the send queue, False to add the row but mark it as do not send. Useful when you want the row visible in the send form but deselected by default.
  • PageNumber — use <Page> to pass the current report page number. Articles uses this to link the email entry to the correct page in the preview.

Tip: You can mix the PagebyPage component and PagebyPageEmailAdd in the same report. For example, use the component for the standard customer email and use PagebyPageEmailAdd in script to conditionally add a manager copy only when the invoice total exceeds a threshold.

Sending the Emails

After the report has been generated and the preview is shown, Articles opens the Page by Page Email send form automatically. From here you can:

  • Review the list of pages and their recipient addresses, subjects, and send status.
  • Check or uncheck individual rows to include or exclude them from the send run.
  • Use Select All or Select None to quickly toggle all rows.
  • Use Reset Sent to clear the sent flag on all rows so they can be resent.
  • Override the Email Subject and Email Body fields at the top of the form — these fill in any rows where the PagebyPage component left those fields blank.
  • Choose the export format from the dropdown. This defaults to the format set in the ReportType component.
  • Click the Export Settings button to review or change the export options for the selected format.
  • Choose whether to send each page as a separate attachment or combine all pages for a recipient into a single attachment.
  • Click Send to deliver the emails.

Tips and Common Mistakes

  • If pages are not separating correctly, check that the GroupHeader has StartNewPage set to True.
  • If all pages go to the same address, check that the EmailAddress property contains a field expression and not a hardcoded value from a previous test.
  • The EmailAttachmentName should not include a file extension — Articles appends the correct extension based on the export format automatically.
  • Leaving EmailSubject or EmailBody blank on the PagebyPage component is intentional — it tells Articles to use the ReportType defaults, which you can still override on the send form before clicking Send.
  • When using PagebyPageEmailAdd in script alongside PagebyPage components, be aware that both will queue entries. If you want script-only control, remove the PagebyPage components from the band.
  • You can run the report and use the send form without actually sending by closing the form — no emails are sent until you click the Send button.