Hi ,
I am trying to save email as a draft. I know there is no direct activity to do this. I am using Run PowerShell Script action to do this. I am using below script.
# Create an Outlook application object
$outlook = New-Object -ComObject Outlook.Application
# Create a new email item
$email = $outlook.CreateItem(0) # 0 represents an olMailItem, which is an email item
# Set email properties (Subject, Recipients, Body)
$email.Subject = "Updated Schedule."
$email.To = """ %ToEmail% """
$email.HTMLBody = %FinalHTML%
# Display the email as a draft
$email.Save()
# Release the COM objects
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($email) | Out-Null
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($outlook) | Out-Null
Remove-Variable email, outlook -ErrorAction SilentlyContinue
I am using below html code in finalHTML variable used in above script.
"<!DOCTYPE html>
<html>
<head>
<style>
/*Internal CSS using element name*/
body{background-color:lavender;
text-align: center;}
h2{font-style: italic;
font-size: 30px;
color: #f08080;}
p{font-size: 20px;}
/*Internal CSS using class name*/
.blue{color: blue;}
.red{color: red;}
.green{color: green;}
</style>
</head>
<body>
<h2>Learning HTML with internal CSS</h2>
<p class="blue">This is a blue color paragraph</p>
<p class="red">This is a red color paragraph</p>
<p class="green">This is a green color paragraph</p>
</body>
</html>"
Error I am receiving.
At C:\Users\bysanil\AppData\Local\Temp\Robin\4czlod5enu3.tmp.ps1:30 char:15
+ <p class="blue">This is a blue color paragraph</p>
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'blue">This is a blue color paragraph</p>
<p class="red">This is a red color paragraph</p>
<p class="green">This is a green color paragraph</p>
</body>
</html>"' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Can you please let me know what's the issue here. Is there any other way that I can accomplish this.
Thank you in advance.