VBA创建内容类型的Outlook消息:多部分/相关? [英] VBA to create Outlook message of Content-Type: multipart/related?

查看:89
本文介绍了VBA创建内容类型的Outlook消息:多部分/相关?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VBA创建带有嵌入式图形的html电子邮件.我的研究表明,我需要将内容类型设置为multipart/related,将图形添加为消息的一部分,为每个图形指定一个内容标识符(CID),然后将每个图形的html img标签src属性设置为cid:theIdentifierString

I'm trying to use VBA to create an html email message with embedded graphics. My research indicates that I need to set my content-type to multipart/related, add the graphics as parts of the message, specify a content identifier (CID) for each graphic, then set each graphic's html img tag src attribute to cid:theIdentifierString

任何人都有一些很好的资源,可以帮助您通过VBA实现此功能以编写Outlook脚本?

Anyone have some good resources on how to achieve this via VBA for scripting Outlook?

推荐答案

您不能直接在Outlook中创建MIME邮件-这不是其本机格式.例如,当它需要通过SMTP服务器发送时,它将在其onw上创建MIME消息.

You do nto directly create MIME messages in Outlook - it is not its native format. It will create MIME message on its onw when it, for example, needs to send through an SMTP server.

话虽如此,创建一个附件并设置PR_ATTACH_CONTENT_ID属性(DASL名称为" http://schemas.microsoft.com/mapi/proptag/0x3712001F ),使用Attachment.PropertyAccessor.

That being said, create an attachment and set the PR_ATTACH_CONTENT_ID property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x3712001F") using Attachment.PropertyAccessor.

您的HTML正文(MailItem.HTMLBody属性)随后将需要通过cid引用该图像附件:

Your HTML body (MailItem.HTMLBody property) would then need to reference that image attachment through the cid:

img src ="cid:xyz"

img src="cid:xyz"

其中xyz是PR_ATTACH_CONTENT_ID属性的值.

where xyz is the value of the PR_ATTACH_CONTENT_ID property.

使用 OutlookSpy 查看现有邮件(单击IMessage按钮).

Look at an existing message with OutlookSpy (click IMessage button).

attachment = mailitem.Attachments.Add("c:\temp\MyPicture.jpg")
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "MyId1")
mailitem.HTMLBody = "<html><body>Test image <img src=""cid:MyId1""></body></html>"

这篇关于VBA创建内容类型的Outlook消息:多部分/相关?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆