Sweep Network folder for a daily file

41 Views Asked by At

I have written a macro to execute in Outlook to find a specific .csv file and attach it to an email and send to specific individuals and it works great.

However, I need to modify it so instead of selecting that specific file it sweeps the folder and selects the file with a DateModified of today(daily) or some sort of CONTAINS naming convention that reads today's date. I assume it'll be some sort of IF(today.getMonth()+1)+ today.getDate()+today.getYear() but I can't seem to figure it out.

Folder Reference

Thank you for your help!!

Sub Send_CollectionsEmail_with_Attachment()
    
    
    Dim OutlookApp As Object
    
    Dim OutlookNamespace As Object

    
    Set OutlookApp = Outlook.Application 
    Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
    
Dim MyMail As Object
Set MyMail = OutlookApp.CreateItem(olMailItem)

MyMail.To = "[email protected]"
MyMail.CC = "[email protected]"

MyMail.Subject = "DQ_Business_Loans_Daily"
MyMail.Body = "Please see the attached report."

Attached_File = "\DQ BUSINESS LOANS\DQ_Business_Loans_20240307.csv"
MyMail.Attachments.Add Attached_File

MyMail.Send

' Clean up Outlook objects
    Set OutlookNamespace = Nothing
    Set OutlookApp = Nothing

End Sub
0

There are 0 best solutions below