Forum Discussion
DabearMDF58
Apr 03, 2024Copper Contributor
Trying to Send IRM Encrypted Email But Body Of Email Is Blank
0 I am writing a script that will open an encrypted Outlook Template File to send and encrypted email. However, the body of the email is not popluating. Code below. Any help would be appreciat...
DabearMDF58
Apr 03, 2024Copper Contributor
Hey Lain,
I have tried both properties and then both come up blank.
I have tried both properties and then both come up blank.
LainRobertson
Apr 03, 2024Silver Contributor
Did you assign HTML content to that attribute?
$Mail.HTMLBody = "<html><body>Please Double Check The Vendors Email Address And Then Enter It Again</body></html>";
Cheers,
Lain
- DabearMDF58Apr 03, 2024Copper Contributor
Yeah I tried that. I even used ConvertTo-Html and set that as the Body and piped it to a variable and then added the variable to the htmlbody property.
- LainRobertsonApr 03, 2024Silver Contributor
Two random quick mentions as afterthoughts:
- Your code sample features smart quotes around the HTMLBody string value, which may be a non-issue if they're only in this web content (but they would be an issue if they're somehow really in your PowerShell code);
- If your template is HTML-based and has already got a value for HTMLBody, then you'd want to be sure that the text you're adding either fully replaces the existing value or that you're inserting it correctly into the existing string block, as if things like tags don't match or free text exists outside of allowable boundaries, it won't render.
But again, these are just afterthoughts and may have no relevance to your test at all.
Cheers,
Lain
- DabearMDF58Apr 04, 2024Copper ContributorAs you have shown and in my own testing, I can get text to show in a non-IRM flagged email. However, I am trying to use a IRM flagged email.
- LainRobertsonApr 03, 2024Silver Contributor
Odd.
I finally got a few minutes to test and it checks out for me.
Script
$outlook = New-Object -ComObject outlook.application $Vendor = "Nobody's Home Furniture"; $Mail = $outlook.CreateItemFromTemplate("D:\Data\Temp\Forum\Forum.oft"); $Mail.SentOnBehalfOfName = "lain.robertson"; $Mail.To = "email address removed for privacy reasons"; $Mail.CC = "email address removed for privacy reasons"; $Mail.Subject = "User With The Email $Vendor Was Not Found"; $Mail.HTMLBody = "<html><body>Please Double Check The Vendors Email Address And Then Enter It Again</body></html>"; $inspector=$Mail.getinspector; $inspector.display();Output
Edited to resolve issues with smart quotes in all strings from the original script.
Cheers,
Lain