Results 1 to 3 of 3
  1. #1
    BYizz is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    1

    I need to automatically download and import an Excel file from an email


    Every morning, one of our employees gets an email with an Excel file that must be downloaded, and the pertinent data must then be transferred to another Excel file were it is then sent to a queue for an ERP system. This seems like an unnecessary task. I need to develop a way to automatically download the excel file from the email every time it is sent, then automatically send the necessary data to another Excel file so it can be imported to a queue. Is there a way to automatically download Excel files from emails using Access? Thanks!

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,443

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,443
    These are the references I used:

    Microsoft Office 12.0 Access database engine objects
    Microsoft Office 12.0 Object Library
    Microsoft Office Outlook 12.0 Object Library
    OLE Automation
    Microsoft Access 12.0 Object Library
    Visual Basic for Applications

    this is the code I used:

    Code:
    Dim nameSpace As nameSpace
    Dim InboxFolder As MAPIFolder
    Dim outlookItem As Object
    Dim mailAttachment As Outlook.Attachment
    Dim fName As String
    Dim InboxItems As Outlook.Items
    
    Set nameSpace = GetNamespace("MAPI")
    Set InboxFolder = nameSpace.GetDefaultFolder(olFolderInbox)
    Set InboxItems = InboxFolder.Items
    
    For Each outlookItem In InboxItems
        For Each mailAttachment In outlookItem.Attachments
            fName = "C:\Test\" & mailAttachment.FileName
            mailAttachment.SaveAsFile fName
        Next mailAttachment
    Next outlookItem
    it correctly downloaded all attachments from the inbox into the c:\test\ folder

    If you wanted to check a specific email from address or test the subject line etc you could do that as well.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 10-31-2013, 06:51 AM
  2. Import Data from Excel File
    By zwieback89 in forum Import/Export Data
    Replies: 1
    Last Post: 06-27-2012, 08:44 AM
  3. Sending excel file in an email
    By Jim.H. in forum Access
    Replies: 1
    Last Post: 01-29-2012, 12:56 PM
  4. import excel files into access automatically
    By jstei012 in forum Import/Export Data
    Replies: 1
    Last Post: 12-19-2011, 04:12 PM
  5. Replies: 0
    Last Post: 08-20-2010, 09:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums