我已经发布了与此相关的问题(电子邮件未显示),并更新了我的脚本以包含cid,但是现在我的图像已附加,而不是内嵌.我不确定如何在Outlook对象中使用嵌入式图像.
I already posted a question related to this (HTML embedded image in the email not displayed ) and updated my script to include cid, but now my images are attached rather than coming inline. I am not sure how I can use inline images in outlook object.
$Text --> "<br /><font face='Arial'><b><i>For Full Interactive Viewing <a href=www.google>Click Here</a></i></b></font><br/>" $MessageImages --> <br/><img src='cid:Volume.png'/><br/><br/><hr><br/><img src='C:\MyImages\Value.png'/><br/><br/><hr><br/><hr> $FinalText = $Text+$MessageImages然后我要创建一个Outlook对象并将其与附件一起发送.
Then I am creating an outlook object and sending it with attachments in it.
$o = New-Object -com Outlook.Application $mail = $o.CreateItem(0) $mail.importance = 2 $mail.subject = "Reports - Automated Email from user list " $mail.HTMLBody = $FinalText $mail.SentOnBehalfOfName ="*********" $mail.To = "*******" $mail.Attachments.Add($file.ToString()) $mail.Send()它已附加,没有任何问题,但未嵌入嵌入式.任何人都可以帮忙.
It is attached without any issue, but not embedded inline. Can anyone help on this.
我没有smtp服务器详细信息,所以我不能使用smtp客户端.因此,我尝试如下使用此类System.Net.Mail.Attachment,但是当我尝试如下添加附件时,
I dont have smtp server details and so I cannot use smtp client. So I tried to use this class System.Net.Mail.Attachment as below, but when I tried to add the attachment as below,
PS H:\> $file Directory: C:\Users\Images Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 23/09/2015 4:04 p.m. 132361 Volume.png $attachment = New-Object System.Net.Mail.Attachment –ArgumentList ($file.FullName).ToString() $attachment.ContentDisposition.Inline = $True $attachment.ContentDisposition.DispositionType = "Inline" $attachment.ContentType.MediaType = "image/png" $attachment.ContentId = $file.Name.ToString() $mail.Attachments.Add($attachment)我收到此错误-
Exception calling "Add" with "1" argument(s): "Value does not fall within the expected range." At C:\work\Automated.ps1:130 char:23 + $mail.Attachments.Add <<<< ($attachment) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ComMethodTargetInvocation有人可以协助我如何在Outlook对象中使用嵌入式图像吗?
Can someone assist me on how to use inline images in outlook object.?
推荐答案您需要将PR_ATTACH_CONTENT_ID属性设置为cid属性(在您的情况下为Volume.png)的匹配值:
You will need to set the PR_ATTACH_CONTENT_ID property to the matching value of the cid attribute (Volume.png in your case):
$attach = $mail.Attachments.Add($attachment) $attach.PropertyAccessor.SetProperty("schemas.microsoft/mapi/proptag/0x3712001F", "Volume.png")更多推荐
使用Powershell中的Outlook对象将图像嵌入到电子邮件中
发布评论