Read mail attached excel files

4

Is there an easy way to data read excel files that are attached in emails in Outlook? Im sure this is scriptable, but I dont particularly want to write it.

Is there a program out there that can accomplish this?

Keltari

Posted 2011-11-29T18:34:58.040

Reputation: 57 019

Answers

1

A broad answer given your question wasn't very detailed

  • ie what do you mean by read,
  • all messages in a folder etc)

You can strip all the Excel files from all messages in an Outlook folder with the following VBA

This code looks at messages in a Outlook folder called "temp" below the Inbox Any Excel files as attachments are saved to C:\test

Other sample code at https://stackoverflow.com/questions/7890612/excel-vba-code-to-save-an-attachment-excel-file-from-an-outlook-email-that-was

Sub SaveOlolAttachments()

    Dim olFolder As Outlook.MAPIFolder
    Dim olMsg As Outlook.MailItem
    Dim olAtt As Outlook.olAttachment
    Dim fsSaveFolder As String
    strSaveFolder = "C:\test\"

    'My testing done in Outlok using a "temp" folder underneath Inbox
    Set olFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    Set olFolder = olFolder.Folders("Temp")
    If olFolder Is Nothing Then Exit Sub

    For Each olMsg In olFolder.Items
        For Each olAtt In olMsg.olAttachments
            If Right$(olAtt.FileName, Len(olAtt.FileName) - InStrRev(olAtt.FileName, ".")) Like "xl?*" Then olAtt.SaveAsFile fsSaveFolder & olAtt.FileName
        Next
    Next
End Sub

brettdj

Posted 2011-11-29T18:34:58.040

Reputation: 1 912

cool thanks, i will test it out. will have to tweak it a little to grab the right files and save them uniquely. – Keltari – 2011-12-08T16:39:52.293