Customizing Email Messages and Subject Lines with Search Expressions
- Introduction
- In this tutorial, we'll look at how an email subject line and message body can be customized via a text search when using the AutoDocMail™ plug-in. This may be useful for automatically sending documents without the need to manually edit individual email messages/subject lines being sent to each recipient.
- This method uses regular expressions to identify specific text within the attachments, and insert it into the accompanying email message body/subject line. A unique email for each recipient is generated, containing only the corresponding data.
- Input Document Description:
- In this example, we use a PDF document containing five ‘pay stubs’ to be sent to various recipients, one-per-page. Each paystup contains a heading that states the payment period. We will use a search expression that identifies this text, extracts "March 2021", and inserts it into the generated subject line (see image above).
- There is also a greeting line beginning with the word "Dear...", as well as various employee-specific text in the actual payslip. We will use a search expression that identifies the greeting line, and extracts the entire line so that the accompanying emailed messages contain this text.
- Lastly, we will use an expression that matches with a unique identification number (Employee Number) within the attachment, and insert it into the message body. The same method could be used to extract any text/number that follows a unique pattern, such as addresses, phone numbers, social security numbers etc.
- This text could even feature within attachments as white text on a white background - or be covered by other document components. The text simply needs to feature somewhere within the document as ‘readable’ text. Using white text may be handy if it is not suitable for it to be visible as part of the attachment. In this example below, all text has been left clearly visible to simplify the demonstration.
- The goal is to send five separate emails - one to each employee - to the email addresses located on each payslip. Each email will have the corresponding payslip attached (as a PDF), and will feature a customized subject line and message body that is unique for each recipient.
- Prerequisites
- You need a copy of Adobe® Acrobat® Pro DC along with the AutoDocMail™ plug-in installed on your computer in order to use this tutorial. Both are available as trial versions.
- Step 1 - Open the "Auto-Email Documents" Dialog
- Start Adobe® Acrobat® and select “Plug-ins > Auto-Email Documents…” from the main Acrobat menu.
- Step 2 - Access Emailing Settings
- In the "Auto-Email Documents" dialog, press the "Settings..." button.
- Step 3 - Edit Settings
- This opens a dialog showing a list of saved settings configurations. Click the “New…” button to configure new settings, or double-click on “Default” settings to modify these. Any settings configuration can also be changed by selecting it and pressing the "Edit..." button.
- Step 4 - Select "Document Processing" Options
- Now open the "Document Processing" tab.
- On this screen, select the “Split input documents into separate files…” option. This is necessary because we are going to process a single PDF file that contains multiple sub-documents (pay stubs), and each sub-document needs to be separately emailed to a different recipient. (If you are sending files that are already split for each recipient, leave the 'Send input documents "as is"...' option selected.)
- Now use the "Specify the number of pages per individual output file” feature by typing a number in to the box. This example uses “1” as each pay stub occupies one page.
- Optional: check “Combine files for each email recipient into a single document” to ensure that each recipient receives a single email, in case there are multiple document pages containing the same email address. Do not use this option if any documents contain multiple email addresses, or if CC/BCC addresses are used.
- Next, open the "Default Message Settings" tab.
- Step 5 - Customize "Default Message Settings"
- On this screen, enter template 'Subject' and 'Message' text to be sent with all outgoing emails. Search expressions using regular expression syntax can be used in the "Subject:" and "Message:" fields, to search for and extract text from the corresponding attachment. Expressions must be enclosed within ##....##. Note that search expressions are case-sensitive.
- In this example, we will use ##Period of Payment: \K[^\n]+## to generate part of each subject line. This will search attachments for the text "Period of Payment:", and extract all of the text that follows on this line. We will also use ##^Dear [^\n]+## to extract the greeting line from the document and use it to start an email message. This produces a customized message that is relevant to the recipient. On the next line, we will use ##Employee Number: \d{8}## to extract the corresponding "Employee Number:" from each payslip and insert it into the template message. Reusing this settings configuration means that identically-formatted documents could be sent using this method, in the same way every month (or any payslip period).
- Search Expressions Breakdown:
- ##Period of Payment: \K[^\n]+## - searches for the text "Period of Payment:" followed by a space, then one or more letters (March 2021). "\K" – removes all matching text to the left in the search results. Using this element means that the subject lines will NOT contain the text "Period of Payment:" - e.g.: only "March 2021".
- ##^Dear [^\n]+## - searches for a new line that starts with the word "Dear" followed by one or more letters, and extracts all text until the end of the line.
- ##Employee Number: \d{8}## - searches for the text "Employee Number:", followed by a space and an 8-digit number.
- Any other plain text entered in these boxes will be displayed in the output as it is typed here. For example, using "ABC Corp. Payslip for ##Period of Payment: \K[^\n]+##" will generate this subject line: "ABC Corp. Payslip for March 2021".
- Using the input shown in the image below will produce the following output:
-
Subject:
ABC Corp. Payslip for March 2021
Message:
Dear Paul Davis,
Here is the weekly payslip for Employee Number: 18027834
- If necessary, manually specify any TO, CC, or BCC recipients, who should receive a copy of each email.
- Press "OK" to finish configuring settings.
- Step 6 - Finish Configuring Settings
- Press “Close” to close the settings screen and proceed to processing your documents.
- Step 7 - Select the Source File
- In the "Auto-Email Documents" dialog, press the "Add Files..." button to select the source PDF file(s) that needs to be distributed. In this example, this is the PDF containing multiple pay stubs.
- Locate the file, select it, and press "Open".
- The input file path and it's number of pages will now be listed in the dialog. Press "Next >" to proceed.
- Step 8 - Review Email Recipients
- Once the document is split and processed, the “Confirm Email Recipients” dialog opens. Double-click on any record in the list to preview the attachment and generated e-mail.
- Step 9 - Preview Attachment and Email Content
- This "Document Preview" window allows you to review the attachment. Now press “Edit Email Settings".
- This window shows the email being sent along with the relevant attachment. The 'subject' and 'message' fields have been auto-populated with the text entered in step 4. The corresponding text has been identified via the search expressions, extracted from the attachment, and inserted into the subject line and message body. All fields can be manually edited here - optionally customize each message/subject, or add recipients by typing in the appropriate boxes.
- Click “OK” when finished.
- Now press "OK" to close the "Document Preview" dialog.
- Step 10 - Confirm Recipients
- Optionally check each generated email by double-clicking on more records and proceeding to the "Edit Email Message" dialog. Each one will have been created using the relevant "Dear..." greeting line and "Employee Number:" within each attachment.
- Before completing the email distribution, use the checkboxes to control which recipients will receive the emails.
- When ready, press “Send”.
- A dialog box will appear prompting the user to confirm the procedure. Click “Yes” to start emailing the documents.
- Step 11 - Processing Emails
- The “AutoDocMail Plug-in - Processing Documents” window opens, displaying the progress of the procedure. This window disappears once mass-distribution of all documents is complete.
- Unless deactivated under the "Email Settings" tab when configuring the AutoDocMail settings, Outlook (if used) will prompt for confirmation of the sending of each email. When this dialog appears, press "Allow" each time to approve the email being sent. Sending emails and attachments using this method is much faster when this option is unchecked.
- Step 12 - Finish the Procedure
- When processing is completed, the “Auto Email Documents” window opens, informing the user of how many emails were successfully sent and if any errors occurred. If any errors are encountered, optionally press the "Save..." button to save a processing report in *.txt format. This file displays detailed information about emails sent successfully and any errors that occurred.
- Click “OK” to finish.
- Click here for a list of all step-by-step tutorials available.