Home General Discussion

Email notifications

Alfie_ThomasAlfie_Thomas Customer IT Monkey ✭

Hi all,

Does anyone currently do/know a way of extracting the change calendar so it could then be emailed around. I cannot see anything obvious in the portal or SCSM to setup an email template etc.


Regards,



Answers

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭

    Could you expand on when you say extract? Do you mean:

    • Parsing the underlying data into a custom HTML email
    • Taking a screenshot of sorts so its near exact calendar and sending that
    • Just sending an SCSM Notification with a link to the page


    Just want to make sure I'm not misinterpreting your desired end goal

  • Alfie_ThomasAlfie_Thomas Customer IT Monkey ✭

    Hi Adam,

    Sorry I wasn't that clear to be honest. I would go with parsing the data into a custom HTML email or either a screenshot and sending it.


    Management want this sent out so they can be made aware of what is up and coming (Even though they can see this in the portal). I guess It is easier to send around if it's in email.


    Kind regards,

  • Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭
    edited March 2021

    All good!

    I've historically addressed requests like this in the past with some really light PowerShell. In the following example I get all of the Change Requests whose Scheduled Start Date occurs within the week (i.e. the time this script is run). Then an HTML email is built based on the returned data showing the ID, Title, Description, and Scheduled Start Date.

    #get the changes that are In Progress
    $crClass = Get-SCSMClass -name "System.WorkItem.ChangeRequest$"
    $now = Get-Date
    $7DaysFromNow = $now.AddDays(7)
    $upcomingChanges = Get-SCSMObject -Class $crClass -Filter "Status -eq '6d6c64dd-07ac-aaf5-f812-6a7cceb5154d" | Where-Object {$_.ScheduledStartDate -lt $7DaysFromNow}
    
    #format them and email
    $htmlChanges = ($upcomingChanges | Select-Object Id, Title, Description, ScheduledStartDate | ConvertTo-Html -Fragment) -replace "<table>", "<table border='1'>" -join ""
    Send-MailMessage -to "user@domain.tld" -from "scsm address" -subject "Changes planned this Week" -Body $htmlChanges -BodyAsHtml -SmtpServer "mailServerHere"
    


  • Alfie_ThomasAlfie_Thomas Customer IT Monkey ✭

    Hi Adam,


    Thanks for this. This is close to what I need.


    It is currently bringing back every "In Progress" CR that we have and not the next 7 days worth?

Sign In or Register to comment.