0

My current script creates (after an account modification) a .ps1 file that is send to another computer and there it is executed opening a new Gmail tab with some information hosted in several variables. I need this email to have format like bold, hyper-link, etc. Im using the start-process 'mailto' for this but i can not find the way to give this email a format (believe me, i have tried), is this even possible?

I appreciate any insights on this.

My current script creates (after an account modification) a .ps1 file that is send to another computer and there it is executed opening a new Gmail tab with some information hosted in several variables. I need this email to have format like bold, hyper-link, etc. Im using the start-process 'mailto' for this but i can not find the way to give this email a format (believe me, i have tried), is this even possible?

Additional information:

Code:

$outPut = 'Start-Process'
$outPut+= '"mailto:'+$userMail+"?Subject=Password Reset"+"&Body=Hi,     your password is $Password"
$outPut+= '";'
$mailFile = "Path" + $user.SAM + ".ps1"
$outPut | Out-File $mailFile

So, this takes the information this way and stored it in a ps1 file, then executed, opening a new Gmail tab with proper data. I need that some words has format, bold for the password or hyper-link for guideness link... Regards!

emerello
  • 1
  • 2
  • 2
    please, show what you have tried ... and how it failed to do what you need. ///// the 1st thing i would look into would be `ConvertTo-Html`, – Lee_Dailey Apr 30 '20 at 22:53

1 Answers1

0

You haven't provided any indication of what you are doing. But the way to send emails via PowerShell is with the Send-MailMessage cmdlet. If you are using Send-MailMessage and formatting the body of the message with HTML, you just need to make sure you are using the -BodyAsHtml argument.

Here's an example:

$html = "<body><h1>Heading</h1><p>paragraph.</p></body>"

Send-MailMessage -To "bob@fake.com" -From "me@fake.com" -Subject "Test" -Body $html -BodyAsHtml
philselmer
  • 751
  • 4
  • 22