HTML in New Starter Script

Welcome Forums General PowerShell Q&A HTML in New Starter Script

Viewing 2 reply threads
  • Author
    • #200705
      Topics: 8
      Replies: 9
      Points: 138
      Rank: Participant

      <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:</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
            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;}
      #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
    • #200801
      Topics: 12
      Replies: 1642
      Points: 2,660
      Helping Hand
      Rank: Community Hero

      Two basic methods:


      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.

    • #200825
      Topics: 8
      Replies: 9
      Points: 138
      Rank: Participant

      Hi Rob

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

      Thanks very much!

Viewing 2 reply threads
  • The topic ‘HTML in New Starter Script’ is closed to new replies.