i am trying to insert the images from desktop in outlook mail body through powershell script, mail is going with below script but images not coming in mail body. please check and tell me where i am doing wrong. please note I dont want as attachment i want it in mail body.please help it will really very appreciable.
Below is the powershell script.
$file1 = "C:\Users\rony\Desktop\screenshot.png"
sleep 02
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "rony7@gmail.com"
$Mail.Subject = "screenshot status"
$Mail.HTMLBody = @"
<html>
<body>
Hi ,
<p>Please find the below screenshots of status.
<p>
<img src="cid:image1.png">
<p>Thank you!
</body>
</html>
"@
$attachment = New-Object System.Net.Mail.Attachment($file1)
$attachment.ContentDisposition.Inline = $True
$attachment.ContentDisposition.DispositionType = "Inline"
$attachment.ContentType.MediaType = "image/png"
$attachment.ContentId = 'image1.png'
$Mail.Attachments.Add($attachment)
sleep 05
$Mail.Send()