0

I am creating a draft email with the help of other post from the forum. I Have that code

$out= New-Object -comObject Outlook.Application
$sign= Get-Content "C:\Users\Roaming\Microsoft\Signatures\sign.htm"           
$recipient= "user@.com
$new= $out.CreateItem(0)
$new.Subject = "Meeting details"
$new.Body = "Meeting details
Date
Time: 
Participants: 
Purpose: 
Current status: 
Act
Next steps:
1)
2)
3)
4)
5)
Thanks,
" 
[Void]$new.Recipients.Add($recipient) 
$new.save() 
$new.HTMLBody = $sign


$display= $new.GetInspector
$display.Display()

The script is creating a draft email with all details I want at the format I want but when I am trying to insert also a signature I have created at Outlook I am getting an error. Thanks

Demont
  • 15
  • 6

1 Answers1

0

You could only use one of the .HTMLBody and .Body.

Please refer to the below code:

$out= New-Object -comObject Outlook.Application
$sign= Get-Content "C:\Users\Roaming\Microsoft\Signatures\sign.htm"           
$recipient= "user@.com
$new= $out.CreateItem(0)
$new.Subject = "Meeting details"
$new.HTMLBody = "<span>Meeting details</span><br>
<span>Date</span><br>
<span>Time:</span><br>
<span>Participants: </span><br>
<span>Purpose:</span><br>
<span>Current status:</span><br>
<span>Act</span><br>
<span>Next steps:</span><br>
<span>1)</span><br>
<span>2)</span><br>
<span>3)</span><br>
<span>4)</span><br>
<span>5)</span><br>
<span>Thanks,</span><br>
" 
$new.Recipients.Add($recipient) 
$new.save() 
$new.HTMLBody += $sign

$display= $new.GetInspector
$display.Display()

Reference from:

Create Outlook email draft using PowerShell

Alina Li
  • 884
  • 1
  • 6
  • 5