I am new to the VBA thing and mostly find a code online and adapt it to work for me. This time I am not managing
What I am attempting to do is email the latest .pdf file attachment from multiple folders that will be specified in multiple cells.
I am new to the VBA thing and mostly find a code online and adapt it to work for me. This time I am not managing
What I am attempting to do is email the latest .pdf file attachment from multiple folders that will be specified in multiple cells.
Could not send the code in text so had to send a image of what I have and the problem Im running into.
Option Explicit
Sub SendMail()
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim blRunning As Boolean
blRunning = True
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If olApp Is Nothing Then
Set olApp = New Outlook.Application
blRunning = False
End If
On Error GoTo 0
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.Subject = "Benchmarking"
.Recipients.Add Range("c2").Value
.Recipients.Add Range("c3").Value
.Recipients.Add Range("c4").Value
.Recipients.Add Range("c5").Value
.Attachments.Add Range("g2").Value
.Attachments.Add Range("g3").Value
.Attachments.Add Range("g4").Value
.Attachments.Add Range("g5").Value
.Body = "New benchmarking reports"
.Display
End With
If Not blRunning Then olApp.Quit
Set olApp = Nothing
Set olMail = Nothing
End Sub