0

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()
visshal7
  • 13
  • 2
  • _… its not working for me_. Please [edit] the question and elaborate this slightly vague statement. Follow [ask] and [mcve]. – JosefZ Sep 08 '18 at 11:37
  • Please check again.. above is the script created to send mail and it will also insert the images from desktop location in the outlook mail body. But the problem is that mail is going but images not showing on mail body. – visshal7 Sep 08 '18 at 12:31
  • [This answer](https://stackoverflow.com/a/30126266/85936) contains some C# code that may help. Other answers on the question are worth reading. – veefu Sep 08 '18 at 21:13
  • Can anyone help me on this... how to insert image on outlook mail body? – visshal7 Sep 09 '18 at 04:43

0 Answers0