I'm restricted in a project, and have to use PowerShell to generate and send emails from Outlook.
param([string]$address, [string]$subject);
$Outlook = New-Object -ComObject Outlook.Application;
$Mail = $Outlook.CreateItemFromTemplate("D:\Users\mark\test.oft");
$Mail.To = "$address";
$Mail.Subject = "$subject";
$Mail.Send();
I'm using an oft template file, as I have to include a company logo embedded image.
However my problem is I need to change some of the body of the email, but retain the embedded graphics and formatting.
Is there a way in PowerShell of passing in a (for example) Reference ID parameter - and replacing in the body of the OFT file, #RefID# with "Reference ID" eg:
param([string]$address, [string]$subject, [string]$RefID);
$Outlook = New-Object -ComObject Outlook.Application;
$Mail = $Outlook.CreateItemFromTemplate("D:\Users\mark\test.oft");
****
$Mail.Body = $Mail.Body.Replace("#RefID#", $RefID)
****
$Mail.To = "$address";
$Mail.Subject = "$subject";
$Mail.Send();
the .Replace above seems to remove formatting, and replaces the logo, with "CID:...."
What it should look like:

What it looks like after using Replace:

Thanks for any help,
Mark
$Mail|Get-Membershould give you a list of properties and methods, this might help.