Friday, March 9, 2012

import data from email attachment

This ones way beyond me, I don't even know where to start. basically we get an email every day with an attachment. The attachment is a csv file. I'd like to import that file into a table in sql. Anyone have any ideas?

Look into SSIS (SQL Server Integration Services)

That would give you everything you need to import the file.

BobP

|||Thanks... I started researching based on your post, and came accross xp_startmail and xp_readmail. These seem to be exactly what i was looking for....except;
xp_startmail gives me the following error;
Either there is no default mail client or the current mail client cannot fulfill the messaging request. Please run Microsoft Outlook and set it as the default mail client.
*** Start mail failed ***

I check outlook and it is the default. I'm using sql server 2005 outlook 2003. I have 2 mail accounts set up on the server, both accounts are bogus accounts that untill now I've used to send mail only (sp_senddbmail). I think I may have to create a real email account that has a corresponding windows account?

With that in mind I tried running xp_startmail using my windows login information and received the same error... ie
xp_startmail 'username', 'password'

|||

Another approach...pros and cons to everything....

Have outlook automatically save any file attachments to a specified folder (see http://www.vbaexpress.com/kb/getarticle.php?kb_id=522 )

Then, in a seperate process, use SSIS or some other mechanism to import the contents of the file.

In my opion, SQL is best when dealing with data rather than email.

Just my $0.02.

No comments:

Post a Comment