sending multiple attachments macro

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
707
Office Version
  1. 365
  2. 2010
so i send a bunch of PDF files as "file name mm-dd" every day where the date is BASED on the previous business day ...also the subject = "title as of mm dd, yyyy"

in the title, I prefer (not necessary) the date format to be May 1, 2015


path of files: G:\a\b\c\yyyy-mm\mm-dd ...here the date format is "2015-05\05-01"

is there a way to macro this via Excel or even outlook itself?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
See here to send E-mails from Excel via Outlook


Mail from Excel with Outlook (VBA)


only issue with this macro is that whever the macro button is placed (e.g.," sheet2"), the macro sends the file based on the last sheet u were on....my colleague doesn't want sheet1 to contain any macro buttons...anyway to click the button on sheert2 and then have the file sent where when it's open via email, sheet1 appears?
 
Upvote 0
only issue with this macro is that whever the macro button is placed (e.g.," sheet2"), the macro sends the file based on the last sheet u were on....my colleague doesn't want sheet1 to contain any macro buttons...anyway to click the button on sheert2 and then have the file sent where when it's open via email, sheet1 appears?

Code:
Sub SendFile()
Dim wb1 As Workbook
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim FileExtStr As String
    Dim OutApp As Object
    Dim OutMail As Object


    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With


    Set wb1 = ActiveWorkbook


TempFilePath = Environ$("temp") & "\"
    TempFileName = wb1.Name
  


    wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    
    Sheets("Sheet2").Select
    
    ActiveWorkbook.EnvelopeVisible = True
    Range("L21:M27").Select


    
    Call setdate
    
    
    On Error Resume Next
    With ActiveSheet.MailEnvelope
         .Item.To = "david_choi@cibcmellon.com"
        .Item.cc = ""
        .Item.Subject = "Treasury Stats for " & m5 & " " & prevd & " " & "," & prevy
        .Item.Attachments.Add TempFilePath & TempFileName
        'You can add other files also like this
        '.Attachments.Add ("C:\test.txt")
        .Item.send   'or use .Display
    End With
    On Error GoTo 0


    'Delete the file
    Kill TempFilePath & TempFileName & FileExtStr


    Set OutMail = Nothing
    Set OutApp = Nothing


    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    
    Sheets("Sheet1").Select
    ActiveWorkbook.Save
  


   
End Sub
 
Upvote 0
so i send a bunch of PDF files as "file name mm-dd" every day where the date is BASED on the previous business day ...also the subject = "title as of mm dd, yyyy"

in the title, I prefer (not necessary) the date format to be May 1, 2015


path of files: G:\a\b\c\yyyy-mm\mm-dd ...here the date format is "2015-05\05-01"

is there a way to macro this via Excel or even outlook itself?

sorry just bumping this
 
Upvote 0
Ok, so run the code using ALT + F8, or or add the code to a button on the QAT and run it when the rquired sheet is active !!
 
Upvote 0
How about sending pdfs ? The Web site seems to only be regarding excel files and worksheets...I know this isn't an outlook forum but maybe someone familiar with vba knows how to solve my problem via outlook
 
Upvote 0

Forum statistics

Threads
1,214,431
Messages
6,119,458
Members
448,899
Latest member
maplemeadows

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top