Sign in
    Shared Email Templates

    Extract data using a regular expression

    With the RegexExtract macro in your template, you can automatically search the Outlook email message you’re replying to for text that matches a regular expression (regex), for example order IDs, extract the matched text, and insert it into your reply. Here’s how:

    1. In the template you’re creating or editing, place the cursor where you want the extracted text to appear.

    2. On the template editor toolbar, select the The Insert macro button Insert macro button.

    3. Select RegexExtract.

    4. In the Regex extract dialog:

      • Select the fields to be searched (message body, From, To, Cc, Bcc, Subject, recipient’s first, last, or full name, sender’s first, last, or full name).
      • Enter a regex that matches the text you want to extract.
      • If you want to make the search case insensitive, select the corresponding checkbox.
      • To return all matches, keep the Extract all matches checkbox selected. To return only the first match, clear the checkbox.
      • If returning multiple matches, enter a delimiter to separate them.

      When you’re finished, select OK.

      The Regex extract dialog
    5. Save your template.

    When you use the template, the selected fields are searched for text matching your regular expression. Depending on your settings, either all matches or only the first one are added to your email message.

    A sample template containing the RegexExtract macro in an Outlook email