View Single Post
 
Old 01-24-2021, 08:00 AM
handclips handclips is offline Windows 10 Office 2019
Novice
 
Join Date: Jun 2020
Posts: 4
handclips is on a distinguished road
Default Attaching all PDFs in folder to Outlook email

Hi

I want to attach all PDFs in a specific desktop folder to an Outlook email using VBA in Word

I'm using below code to generate an Outlook email but cant figure out how to write the attachment part.

Sub Email_Template1()

Dim oMailItem As Object, oOLapp As Object
Dim Word As Object, doc As Object, MsgTxt$
Set oOLapp = CreateObject("Outlook.Application")
Set oMailItem = oOLapp.CreateItem(0)
Set Word = CreateObject("word.application")

With oMailItem
.To = "Email"
.cc = "Email"
.subject = "Needed Confirmation"
' .attachment.Add
.HTMLBody = "test"
.Display
End With

Set oOLapp = Nothing
Set oMailItem = Nothing

End Sub
Reply With Quote