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
as a object in the body of email. Any help on this will be appreciated.
Public Sub CreateNewMessage()
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
With objMsg
.To = "[email protected]"
.Subject = "This is the subject"
.BodyFormat = olFormatHTML
.Attachments.Add ("C:WorkDashbaord.pdf"), olOLE 'Attach PDF File
'Embed PDF
Set wordapp = CreateObject("word.Application")
wordapp.Documents.Open FileName:="C:Work" & "Dashbaord.pdf"
wordapp.Visible = True
'Embed PDF
wordapp.Visible = True
Set wordapp = GetObject(, "Word.Application")
wordapp.Selection.InlineShapes.AddOLEObject ClassType:="AcroExch.Document.11", _
FileName:="C:WorkDashbaord & ".pdf", LinkToFile:=False, _
DisplayAsIcon:=False
.Display
End With
Set objMsg = Nothing
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…