HTML in New Starter Script

<p class="_1qeIAgB0cPwnLhDF9XSiJM">I am trying to send a welcome email to new starters after using a new starter script. Essentially, the starter script waits for them to be created in Office 365 after syncing from our local AD, assigns a license to the user and then waits for the mailbox creation before sending the email. We used to send a welcome email a while ago which I would like to use again but I’m struggling to format it correctly in PowerShell. How can I format the below HTML in PowerShell? Please ignore the content of the email, I need to change that.</p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM">I’m struggling with the different styles that are needed throughout the email.</p>
<p class="_1qeIAgB0cPwnLhDF9XSiJM">The HTML can be viewed here: https://www.w3schools.com/code/tryit.asp?filename=GBDYKDJC7FKK</p>
I found the below online to use as HTML in my script but I’m not sure how to incorporate my welcome email into that:

#Define some variables for the message
#HTML header with styles
$htmlhead="<html>
     <style>
      BODY{font-family: Arial; font-size: 10pt;}
	H1{font-size: 22px;}
	H2{font-size: 18px; padding-top: 10px;}
	H3{font-size: 16px; padding-top: 8px;}
    </style>"
#Header for the message
$HtmlBody = "<body>
     

Welcome to Our Company

<p>Generated: $(Get-Date -Format g)</p>

<u>We're Pleased to Have You Here</u>

" $htmlHeaderUser = "

New User " + $User.DisplayName + "

" $htmlline1 = "<p>Welcome to $company</p>" $htmlline2 = "<p>You can open Office 365 by clicking here </p>" $htmlline3 = "<p>Have a great time and be sure to call the help desk if you need assistance.</p>" $htmlbody = $htmlheaderUser + $htmlline1 + $htmlline2 + $htmlline3 + "<p>" $HtmlMsg = "</body></html>" + $HtmlHead + $HtmlBody

Two basic methods:

HereString
https://gist.github.com/rasimmers/05fe8bf626b8e0137a93a6163e3e7b05

Template File

#Typically use All Caps or something to replace text, like THE_NEW_USER
$htmlTemplate = Get-Content C:\Templates\NewUserTemplate.html
$htmlTemplate -replace 'THE_NEW_USER', $user

Normally, I use a template file because I like to get a template that is tested on every mail client, browser, phone, etc. and they can be bigger, but the content will look great no matter where they look at it. Most of them are free and there are good templates that you just copy and paste chunks of code to format the email however you like.

Hi Rob

I’ll definitely investigate the template method. That seems to be the best option.

Thanks very much!