Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read contents of Outlook Attachment text file

Status
Not open for further replies.

johnnygeo

Programmer
Apr 23, 2003
125
US
I have an Access DB which sends a survey out to users as an HTML POST form embedded in an Outlook email. When the user submits the form, it sends a reply email with the form data in an attached file POSTDATA.ATT. This file is a very simple text file which I was hoping I could read into the Access DB. I need help actually getting to this file from my Inbox and cracking it open to get at the goodness inside. Basically, I want to do something like this:
Code:
Dim myOutlook As Outlook.Application
Dim myNS As Outlook.NameSpace
Dim myfolders As Outlook.Folders
Dim mySurveyFolder As Outlook.MAPIFolder
Dim myEmail As MailItem
Dim myAttach as Attachment    
    
Set myOutlook = CreateObject("Outlook.Application")
Set myNS = myOutlook.GetNamespace("MAPI")
Set myfolders = myNS.Folders
Set mySurveyFolder = myfolders("SurveyAccount").Folders("Inbox")
For Each myEmail In mySurveyFolder.Items
  If myEmail.Attachments.Count > 0 Then
    set myAttach = myEmail.Attachments(1)
    ???????
    ???????
  End if
Next myEmail
the ??????? marks where I would like to read in the attachment's contents. Can I do this directly? If not, I know how to read from a file on my hard drive. But how can I save the attachment?

Thanks,
Johnny Geo
 
myAttach.SaveAs "\path\to\saved"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top