Send a Regular Email Containing a Datamining Report

Modified on Wed, 20 Sep 2023 at 12:53 PM



The article shows how to setup an email to sent on a schedule containing a Datamining Repeprt, either as an attachement, or embedded.

1. Create the Datamining report

  • Create the required Datamining Report
  • Perform any sorting, filtering, reordering and removing of columns in the DMR so that only the columns/rows you want to display in the report remains
  • Click Run Datamining Report
  • Save the DMR
  • Take a note of the Report Id in the window title. E.g 26

2. Create the Email Template

  • Click Administration ->PS Scripts, Emails, Buttons
  • Untick Scripts and Buttons
  • Click on the current project name such as ManagementStudio, or in this example Cloud 2022 (1)
  • Click here to add new item (2)

  • Give the email template a meaningful name and a subject
  • Using the column picker add the CC field to the grid
  • Add an email address (or a semicolon separated list of email addresses) to the CC field. Note that this could also be a distribution group email
  • Click the the Edit button (the scroll icon)
  • Add text to appear at the start of the email such as: Here is the ManagementStudio Datmining report:
  • To embed the report content as a table in the email add this line:


  • To add the report as a file attachment in the email add this line:


  • Replace XX with the Datamining Report ID 

  • If the report was embedded in the email, it's recommended to add borders to the table. To do this add the text below to the start of the email template, with the content underneath:
    table.table {  
         border:solid 1px #c0c0c0;
         border-collapse: collapse;
    tbody th, tbody td, thead th {
         padding: 3px;
         border-width: 1px;
         border-style: solid;
         border-color: #c0c0c0;
         vertical-align: top;
         font-size: 12px;
    thead th {
        text-align: center
  • Click Save Changes
  • Take a note of the email template Id

3. Create a PowerShell script to send the email

  • Untick the Emails option, tick the Scripts option
  • Click on the current Project name, then Click here to add new item
  • Give the script a meaningful name
  • Click the the Edit button (the scroll icon)
  • Add the following line

Send-MSEmails -Module ManagementStudio -ToIds 1 -EmailTemplateId YYY -SpreadOverHours 0 -OverrideSendTo ''

  • Replace YYY with the Email template ID noted from earlier
  • Use the column picker to show the Grant Access 2 column
  • Add the Project Admins role to Grant Access 2
  • Schedule the PowerShell Script to run as required, e.g. every Monday at 12pm, this is when the email will be sent out automatically
  • Click Save Changes

4. Test the Script

  • Click the play button to test the script
  • An email will be sent with the DMR

Further Support

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