Consulting

Results 1 to 4 of 4

Thread: VBA to email multiple .Pdf from specified folders.

  1. #1

    VBA to email multiple .Pdf from specified folders.

    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.

  2. #2

  3. #3
    Could not send the code in text so had to send a image of what I have and the problem Im running into.

  4. #4
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •