email multiple attachments from a folder that i choose


S

Sabosis

Hello-

I have a process where multiple PDF attachments are saved in a network folder, the folder is named with the current date. I know how to send emails through Access, but didn't know how to handle this particular approach.

I wanted to have a process where I run code to generate an Outlook email, the system will let me choose the folder, and all of the PDF attachments within that folder will be added to the email message. Since the name of the folder changes each day, i need to be able to pick the folder that I want tosend the attachments from. Any ideas?

Thanks in advance for the help!

Scott
 
Ad

Advertisements

Joined
Feb 9, 2012
Messages
25
Reaction score
0
Here is some code that will let you choose a folder and then add all .pdfs to an email

Code:
Dim f As Object, strPath As String, varFile As Variable, strTemp As String
Dim oApp As Object, oMessage As MailItem, oRec As Recipient

Set oApp = CreateObject("Outlook.Application")
Set oMessage = oApp.CreateItem(olMailItem)
oMessage.display '
oMessage.Recipients.Add("EMAIL ADDRESS HERE").Type = olTo
oMessage.Subject = "SUBJECT TEXT HERE"
oMessage.body = "BODY TEXT HERE"


Set f = Application.FileDialog(4) '4 = msoFileDialogFolderPicker (File picker dialog box)
With f
    If .Show Then
        strPath = .SelectedItems(1)
    End If
End With

If strPath <> "" Then
    Dim MyObj As Object, MySource As Object, file As Variant
    file = Dir(strPath)
    While (file <> "")
        If Right(file, 3) = "pdf" Then
            oMessage.Attachments.Add strPath & file
        End If
        file = Dir
    Wend
End If

Set oApp = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top