VBA code for downloading excel files from Outlook RRS feed

  • Question

  • I use Outlook 2010. I receive 6 emails on a daily basis, each with a different excel .csv file. Is there a VBA code I can use to download each of them into a folder. These would overwrite the previous days files. 


    Thursday, May 7, 2015 1:21 PM

All replies

  • You could run the following script from a rule to identify the sender(s) and save the CSV fiels on arrival.

    Sub CustomSaveAttachments(Item As Outlook.MailItem)
    Dim olAtt As Attachment
    Dim strFilename As String
    Const strPath As String = "C:\Path\" 'The folder in which you want to save the files
        If Item.Attachments.Count > 0 Then
            For Each olAtt In Item.Attachments
                If Right(LCase(olAtt.FileName), 3) = "csv" Then
                    strFilename = strPath & olAtt.FileName
                    olAtt.SaveAsFile strFilename
                End If
            Next olAtt
        End If
        Exit Sub
    End Sub

    Graham Mayor - Word MVP

    • Proposed as answer by ryguy72 Friday, May 8, 2015 1:54 PM
    Friday, May 8, 2015 4:20 AM