How to Automate T-minus Emails

Modified on Tue, 07 Nov 2023 at 01:06 PM

TABLE OF CONTENTS

Introduction

This guide walks through the steps required to automatically send an email to users 10 days before their Migration Slot. There is an additional section at the end for sending the email when the users are moved into a specific workflow process rather than being time-based.


Prepare Prerequisites

  1. For testing create a Blueprint and add a test User Migration to it
  2. Setup an email template. Administration -> User Migrations -> Email Templates -> Click here to add new item
    1. Email Name: <As required> e.g. "T-minus 10 days"
    2. Subject: <As required> e.g. "Windows 11 Project - 10 days to go..."
    3. Click on the script icon and add the email content. This can be either markdown or HTML.
    4. Click Save Changes

Create the ESM Plan

  1. Administration -> Extensions -> Servicing Plans -> User Migration Plans
  2. Service Plans -> New Service Plan
    1. Plan Name: <As required> e.g "T-minus 10 days email", click New Plan
    2. Schedule Settings -> Tick Reset Prior to Run
  3. Data Source -> Deselect All User Migrations option
  4. Data Source -> Only run on User Migrations in the test Blueprint
  5. Add the test User Migration to a Deployment Unit with a start date and end date which include a date seven days from today
  6. Now the test User Migration needs a migration slot: User Migrations -> All User Migrations -> Double click your user record -> click Update Migration Slot -> Set the migration slot to 7 days in the future from today -> Update
  7. Now we need to ensure the plan only runs against the relevant User Migrations. In the screenshot below the Evaluator is searching for users who are being migrated in the next 13 days (it's 13 rather than 10 to ensure emails aren't sent on a weekend, but rather the Friday before).
  8. Browse to Service Plan Rules -> Add New Setting:
  9. Add the two rules below:
  10. Notes:
    • Rule 1: The Criteria search start date should be set to [Today] to catch late additions to the schedule. I.e. If a user was scheduled to be migrated three days from [Today], they should still receive the email.
    • Rule 2: This defines the search end date. The Criteria should be at least three days greater that the T-minus time in case it falls on a weekend, in which case the email will be sent on the Friday before. In this case it's a T-minus 10 days email, so the criteria is [Today + 13]
    • The email Schedule date (the date the email is actually sent) is dictated by the Plan Actions (not the evaluator rules) which in this case will always be 10 days prior to the migration date. This is configured in a later step. The email queue will therefore show a set of emails scheduled to be sent in the near future for users being migrated in the next 10 days.
    • The email content is generated at the time the email is sent, NOT when it is queued. This ensures the user gets the latest version of the email.
    • It is possible to combine the two rules into a single rule. For examples see the Reference section below.
  11. Click Validate Plan Rules and ensure they pass
  12. Now the action must be created. In Service Plan Actions (Publisher) click Add New Setting
  13. Setup as in screenshot below.
    Ensure the Target matches the email name exactly
    Set Param to Schedule:[DeployUnitSlotStart - 10 @ 08:00];DuplicateCheck:100;LateEmailLimit:10
  14. Notes:
    • The DuplicateCheck setting ensures that duplicate emails are not sent. Set this to at least the t-minus days
    • The LateEmailLimit setting ensures that emails with a scheduled send date which is a long time in the past are not sent in error. Set this to the t-minus days.
  15. Click Validate Plan Actions and ensure it passes

  16. Sae the plan


Test the Plan


  1. Click Reset, Eval, Schedule & Publish

  2. Check the test User Migrarion, Service Plans tab, ensure all logs are as expected

  3. Once it's all setup and working remove the test Blueprint from the plan source (it may be useful to target a specific process for production) and set a Schedule to Run under Schedule Settings as required

Reference



 

Rule Name
Rule Type
Data Location

Operator
Criteria
Description
Has a date setFieldDeployUnitSlotStart!=[Blank]Identifies all assets which have been added to a slot in the DU
Has no date setFieldDeployUnitSlotStart==[Blank]Identifies all assets which have not been added to a slot in the DU
More than 10 days to go (Inclusive)FieldDeployUnitSlotStart>=[Today + 10]Identifies all assets with more than 10 days until they are due to be migrated
Less than 10 days to go (Inclusive)FieldDeployUnitSlotStart<=[Today + 10]Identifies all assets with less than 10 days to go until they are due to be migrated
More than 10 days ago (Inclusive)FieldDeployUnitSlotStart>=[Today - 10]Identifies all assets which have a migration slot more than 10 days ago
Less than 10 days ago (Inclusive)FieldDeployUnitSlotStart<=[Today - 10]Identifies all assets which have a migration slot less than 10 days ago
In the futureFieldDeployUnitSlotStart>[TimeStamp]Identifies all assets which are due to be migrated in the future
In the pastFieldDeployUnitSlotStart<[TimeStamp]Identifies all assets which have a migration slot in the past
Is Between 5 & 10 Days to goFieldDeployUnitSlotStartIs the DayBetween [Today + 5] & [Today + 10]Identifies all assets which are due to be migrated between 5 days and 10 days in the future
Not Between 5 & 10 Days to goFieldDeployUnitSlotStartNot the DayBetween [Today + 5] & [Today + 10]Identifies all assets which are not due to be migrated between 5 days and 10 days in the future (Eg. a user who is due to be migrated tomorrow; a machine which is due to be migrated in 12 days' time, any asset which has a slot in the past)
Is Between 5 & 10 Days agoFieldDeployUnitSlotStartIs the DayBetween [Today - 5] & [Today - 10]Identifies all assets which have a migration slot between 5 days and 10 days ago
Not Between 5 & 10 Days agoFieldDeployUnitSlotStartNot the DayBetween [Today - 5] & [Today - 10]Identifies all assets which do not have a migration slot between 5 days and 10 days ago (Eg. a user with a migration slot 15 days ago; a machine which is due to be migrated in 2 days' time)
Three days to go between 1pm & 7pmFieldDeployUnitSlotStartIs the DayBetween [Today + 3 @13:00] & [Today + 3 @19:00]Identifies all assets which are due to be migrated in 3 days' time, between 1pm and 7pm
Three days ago between 1pm & 7pmFieldDeployUnitSlotStartIs the DayBetween [Today - 3 @13:00] & [Today - 3 @19:00]Identifies all assets which have a migration slot 3 days' ago, between 1pm and 7pm
DeployUniitStart = 2021-01-25FieldDeployUnitSlotStartIs the Day25/01/2021Identifies all assets which are due to be migrated on the 25/01/2021
Compare two datesCompare FieldsDeployUnitSlotStart<=DU:EndDateIdentifies all assets which have a slot which falls in between two dates

Further Support

If you require further support, please visit ManagementStudio's Service Desk to search the knowledge base or create a new support ticket.