Skip to content

Instantly share code, notes, and snippets.

@ppineda32
Created May 14, 2018 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppineda32/19767e72ec062b3ebd8f2e1fb67ec474 to your computer and use it in GitHub Desktop.
Save ppineda32/19767e72ec062b3ebd8f2e1fb67ec474 to your computer and use it in GitHub Desktop.
Create from template. replace date field, replace image and make it inline attachement.
$attachment = Get-Item C:\Users\Akabane\Desktop\2018-05-05_19-20-53.png
$ol = New-Object -comObject Outlook.Application
$mail = $ol.CreateItemFromTemplate('C:\Users\Akabane\Desktop\ajajajajaj.oft')
$mail.HTMLBody = $mail.HTMLBody.Replace('#FECHA#', '10/25/15')
$mail.HTMLBody = $mail.HTMLBody.Replace('#IMAGEN#', '<br /><img src="{0}" />' -f ($attachment.Name))
$attach = $mail.Attachments.Add($attachment.FullName)
$attach.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "2018-05-05_19-20-53.png")
$inspector = $mail.GetInspector
$mail.SaveAs('C:\Users\Akabane\Desktop\template.oft')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment