Importing Outlook .txt Attachment

cgmojoco

Well-known Member
Joined
Jan 15, 2005
Messages
699
Email folder has files with attachments.

I'm able to impor the email headers, body etc. simply by importing via the file menu and selecting Outlook or Exchange.

I'd like to however, import the singe .txt file that is attached to each email.

The .txt file has a set # of columns

Where would I begin? Thanks in advance.

Outlook 2003
Access 2000

Thanks-
Christopher
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I have never imported a text file directly from Outlook to Access, but if the text file is an attachment, simply detach it, and then import it into Access.

From the Table object in Access, go to File | Get External Data | Import and select your file. A wizard should pop-up helping you through the process, where you can specify the format/layout of the incoming data.
 
Upvote 0
Don't know if it helps but the following code saves all attachments to a folder.
Code:
Sub SaveAttachments()
Dim myOlapp As Object
Dim myNameSpace As Object
Dim myFolders
Dim myFolder
Dim myItem
Dim myAttachment As Object

    Set myOlapp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlapp.GetNamespace("MAPI")
    
    For Each myFolders In myNameSpace.Folders
        For Each myFolder In myFolders.Folders
            For Each myItem In myFolder.Items
                If TypeName(myItem) = "MailItem" Then
                    If myItem.Attachments.Count <> 0 Then
                        For Each myAttachment In myItem.Attachments
                            myAttachment.SaveAsFile "C:\MailTest\" & myAttachment.FileName
                        Next
                    End If
                End If
            Next
        Next
    Next
End Sub
You could use this to get all the attachments saved to 1 folder, then code could be used to import each file in that folder.
 
Upvote 0

Forum statistics

Threads
1,226,532
Messages
6,191,611
Members
453,667
Latest member
JoeH7745

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top