Deri
Deri

Reputation: 7

Powershell script to send mail with embedded pictures (under exchange server)

I'm trying to write a PowerShell script to send mails over an Exchange server with embedded pictures:

Start-Process Outlook
$file1='C:\ScreenShots\file1.png'
$file2='C:\ScreenShots\file2.png'

$textBody=""<html>Hello, <br /> <br /> Here are the pictures : <br /> <br /><br   /><tr><td> <img src='$file1'> </img> <br /> <br /></img><img src='$file2'> </img>    </td></tr></table></html>";
$Outlook = New-Object -comObject  Outlook.Application 

$Mail = $Outlook.CreateItem(0) 
$Mail.Recipients.Add("[email protected]") 
$Mail.Subject = "Pictures"
$Mail.HTMLBody= $textBody
$mail.Send()

The mail is sent but the pictures are only available if sent the mail to myself.

Any ideas?

Thanks

Upvotes: 0

Views: 1210

Answers (1)

user189198
user189198

Reputation:

The file paths you specified are on the local filesystem. If you send it to someone else, and they do not have these file paths present on their system, then they will not appear correctly in Outlook.

Upvotes: 1

Related Questions