Results 1 to 4 of 4

Macro to attach all files in a folder

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2021
    Posts
    2,776

    Macro to attach all files in a folder

    I have a macro to create an email and attach a workbook, which works perfectly to attach the active workbbook


    However, I need the macro amended so that it attaches all the csv files in the folder "C:\sales JNLS\

    Your assistance is most appreciated




     Sub Email_filesInFolder()
       ThisWorkbook.Activate                           'start in THIS workbook
    ztext = [bodytext]                              'read in text from named cell
    Zsubject = [subjectText]
    
      Dim OutApp As Object
        Dim OutMail As Object
    Dim Strpath As String
    Dim Strfile As String
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
          With OutMail
    
          
                .To = Join(Application.Transpose(Sheets("Data").Range("AU1:AU2").Value), ";")
    
                .CC = ""
                
                .BCC = ""
                .Subject = Zsubject
               .Body = ztext
              
    
    
                
              .Attachments.Add ActiveWorkbook.FullName
                
               .Display
              End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
       
        
    End Sub
    Attached Files Attached Files
    Last edited by Howardc1001; 11-26-2019 at 03:39 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Attach files created by macro to an email
    By JesseSingh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-04-2016, 12:12 AM
  2. Outlook macro to attach most recently created file from folder
    By lsargent in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2015, 11:45 AM
  3. [SOLVED] Loop Through Folder, Create Emails with Sub Folder Names in Subject, Attach files in sub
    By Rschwar23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2015, 10:06 AM
  4. Help with macro not working - Pull from fields > attach doc from folder > send email
    By mikey386 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-07-2015, 03:42 PM
  5. Excel Email Macro - HELP! - Need to be able to attach two different files
    By benwahchang in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-29-2013, 08:41 AM
  6. Replies: 1
    Last Post: 03-12-2013, 04:45 AM
  7. [SOLVED] Macro to loop through workbooks in folder and attach and email using address in closed WB
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-03-2013, 07:23 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1