How to Embed a PDF Document in an Email Message

前端 未结 1 2049
小蘑菇
小蘑菇 2020-12-12 04:42

I am trying embed PDF into body of my email .

I tried following code but it keeps opening word but attaches pdf file but does not embed pdf

相关标签:
1条回答
  • 2020-12-12 05:05

    Should be something like this.

    Public Sub InsetObject()
        Dim Inspector As Outlook.Inspector
        Dim wdDoc As Word.Document
        Dim Selection As Word.Selection
        Dim Email As Outlook.mailitem
    
        Set Email = Application.CreateItem(olMailItem)
    
        With Email
            .To = "0m3r@Email.com"
            .subject = "This is the subject"
            .Attachments.Add ("C:\Temp\TempFile.pdf")
            .Display
    
             Set Inspector = Application.ActiveInspector()
             Set wdDoc = Inspector.WordEditor
             Set Selection = wdDoc.Application.Selection
    
             Selection.InlineShapes.AddOLEObject ClassType:="AcroExch.Document.DC", _
                       FileName:="C:\Temp\TempFile.pdf", _
                       LinkToFile:=False, DisplayAsIcon:=False
    
        End With
    
        Set Inspector = Nothing
        Set wdDoc = Nothing
        Set Selection = Nothing
    End Sub
    


    InlineShapes.AddOLEObject Method (Word)

    Creates an OLE object. Returns the InlineShape object that represents the new OLE object.


    InlineShape Object (Word)

    Represents an object in the text layer of a document. An inline shape can only be a picture, an OLE object, or an ActiveX control. The InlineShape object is a member of the InlineShapes collection. The InlineShapes collection contains all the shapes that appear inline in a document, range, or selection. InlineShape objects are treated like characters and are positioned as characters within a line of text.


    Reference to Microsoft Word xx.x Object Library

    0 讨论(0)
提交回复
热议问题