Grab info from attachment and put into SQL db

M

manared

I'm very new to VBA, but have been programming with vb.net for several years
now. What I would like to do is grab an attachment (excel), suck out all the
information in that excel file and enter it into a SQL database. I have no
clue how to do that using VBA and Outlook. I'd love to be able to have this
done automatically when the email comes in, but if the user has to click a
button to go through the inbox to grab the specific emails/attachments,
that's alright. I just don't know how to get that attachment info to the
database.
 
E

Eric Legault [MVP - Outlook]

There's no quick and easy answer, but I can guide you down the path.

First, this is a must read:

How to process incoming messages in Microsoft Outlook:
http://www.outlook-code.com/article.aspx?id=62

The next step is to become familiar with the Outlook Object Model:

http://msdn.microsoft.com/en-us/library/bb208225.aspx

Then basically you need to get a handle to the MailItem you want, and grab
the Attachment object you want from MailItem.Attachments collection and call
the Attachments.SaveAsFile method.

See the example here:

http://msdn.microsoft.com/en-us/library/bb219926.aspx

As for exporting the contents of the Excel attachment to SQL - that's not a
question for an Outlook forum! You're looking at ODBC/OLE DB/ADO.NET and the
Excel Object Model for that scenario.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top