我正在尝试通过Powershell脚本在Outlook邮件正文中从桌面插入.images,邮件会发送,但邮件正文中没有图片

时间:2018-09-08 07:58:38

标签: powershell powershell-v2.0 powershell-v3.0 powershell-v4.0

我正在尝试通过Outlook邮件正文从桌面插入图像  powershell脚本,邮件与下面的脚本一起使用,但图像未进入  邮件正文。请检查并告诉我我在哪里做错了。请注意,我不  想要作为附件,我希望它出现在邮件body.please帮助中,它将非常非常  可观的。

下面是powershell脚本。

     $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()

0 个答案:

没有答案