email multiple attachments from a folder that i choose

Discussion in 'Access VBA Modules' started by Sabosis, Jan 14, 2014.

  1. Sabosis

    Sabosis Guest

    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
     
    Sabosis, Jan 14, 2014
    #1
    1. Advertisements

  2. Sabosis

    SoftwareMatters

    Joined:
    Feb 9, 2012
    Messages:
    25
    Likes Received:
    0
    Location:
    Dorset
    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
    
     
    SoftwareMatters, May 9, 2014
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Mercy
    Replies:
    1
    Views:
    99
    Mercy
    Aug 15, 2003
  2. saymard

    how to choose a printer

    saymard, Nov 3, 2003, in forum: Access VBA Modules
    Replies:
    4
    Views:
    107
    saymard
    Nov 6, 2003
  3. dab1477
    Replies:
    2
    Views:
    89
    dab1477
    Nov 19, 2003
  4. Robert Chapman

    Run module & get asked to choose a macro

    Robert Chapman, Feb 9, 2004, in forum: Access VBA Modules
    Replies:
    1
    Views:
    85
    Naresh Nichani MVP
    Feb 9, 2004
  5. KP

    Choose back end

    KP, Apr 29, 2004, in forum: Access VBA Modules
    Replies:
    1
    Views:
    87
    Allen Browne
    Apr 29, 2004
  6. Chris
    Replies:
    2
    Views:
    76
    Reggie
    Jul 28, 2004
  7. Mark

    Send Multiple attachments to email

    Mark, Jan 4, 2008, in forum: Access VBA Modules
    Replies:
    2
    Views:
    128
  8. jsccorps

    If prices equal then choose always choose Vendor A

    jsccorps, Dec 11, 2008, in forum: Access VBA Modules
    Replies:
    3
    Views:
    265
    Michel Walsh
    Dec 15, 2008
Loading...