I have a program that reads and send emails using Outlook automation, from Visual FoxPro.
I have functions to retrieve and save attachments, but I would like to read the contents of an attachment to a string without saving the file to disk.
In the example below, I instantiate Outlook, pick up a namespace and a reference to the current user's inbox. I then pick up a reference to an arbitrary message (number 32 in the inbox), and a reference to the message's attachment.
oOutlook = createobject('Outlook.Application')
oNamespace = oOutlook.GetNamespace('MAPI')
oInbox = oNamespace.GetDefaultFolder(olFolderInbox)
oMessage = Inbox.Items[32]
oAttachment = oMessage.Attachments[1]
At this point I would call:
oAttachment.SaveAsFile('C:\Example\File1.xml')
to save the file to disk.
What I want to do is to read the contents of the file to a string, without saving it to disk.
In this particular instance, the file is XML.