Including Pictures in an Outlook Email

后端 未结 1 1140
日久生厌
日久生厌 2021-01-17 03:17

I\'m trying to use a Microsoft Word document as the body to an Microsoft Outlook email. So far I have been able to include the text from a Word .docx into the body of the em

相关标签:
1条回答
  • 2021-01-17 04:04

    First of all, you are setting the plain text MailItem.Body property. Secondly, create an attachment and set the PR_ATTACH_CONTENT_ID property (DASL name "http://schemas.microsoft.com/mapi/proptag/0x3712001F") using Attachment.PropertyAccessor.SetProperty.

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

    <img src="cid:xyz">
    

    where xyz is the value of the PR_ATTACH_CONTENT_ID property.

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

    EDIT: sample script (off the top of my head):

    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>"
    
    0 讨论(0)
提交回复
热议问题