I recently needed a way to send merged mail through Powershell. That part is easy enough, but to take it a bit further, i wanted to be able to edit the mail in “HTML” format before sending it, without having to write HTML code.
I googled my a** off trying to find a way to do this without having to buy a product to add this. I found plenty for C#, but none ready for Powershell.
What i ended up doing was downloading the one created by Carl Nolan for C# (https://code.msdn.microsoft.com/WinForms-HTML-Editor-01dbce1a) and compiling it using Visual Studio Code. Then i simply took the DLL and loaded in Powershell (DL link for just the dll HERE)
How to load the dll:
Add-Type -Path "C:\Windows\System32\MSDN.HtmlEditorControl.dll"
Then to add the box to display a predefined text in $EmailBody:
$BodyRichBox = New-Object System.Windows.Forms.RichTextBox #RTEditor $System_Drawing_Size = New-Object System.Drawing.Size $System_Drawing_Size.Height = 315 $System_Drawing_Size.Width = 550 $rteditor.MinimumSize = $System_Drawing_Size $System_Drawing_Point = New-Object System.Drawing.Point $System_Drawing_Point.X = 635 $System_Drawing_Point.Y = 135 $rteditor.Location = $System_Drawing_Point $rteditor.Name = "htmlEditorControl" $rteditor.TabIndex = "4" $rteditor.InnerHtml = $EmailBody $rteditor.Font = "Arial" $rteditor.Anchor = "Top,Left,right,Bottom" $System_Windows_Forms_Padding = New-Object System.Windows.Forms.Padding $System_Windows_Forms_Padding.Right = 10 $rteditor.Padding = $System_Windows_Forms_Padding $Form1.Controls.Add($rteditor)
End result for me was this: