Question : Macro to automatically save email attachments

I need someway to automatically save a copy of email attachments to a windows folder.

I am working on VBA automation project that takes raw data contained in CSV files and, using Excel processes the data into a report format.
I recieve the CSV files as email attachments.

Answer : Macro to automatically save email attachments

Hi, afcnoc.

The code below will handle this.  To use this

1.  Add the code to Outlook (be sure to pay attention to the comments in the code)
2.  Create a rule that fires for the messages with the .csv attachments
3.  Set the rule's action to "run a script"
4.  Set this script as the one to run
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Sub SaveCSVToDisk(Item As Outlook.MailItem)
    Dim olkFile As Outlook.Attachment
    For Each olkFile In Item.Attachments
        'Change the file name on the following line'
        If Right(LCase(olkFile.FileName, 3)) = "csv" Then
            'Change the path the file will be saved to on the following line'
            olkFile.SaveAsFile "C:\" & olkFile.FileName
        End If
    Next
    Set olkFile = Nothing
End Sub
Open in New Window Select All
Random Solutions  
 
programming4us programming4us