How do I have Exchange forward emails to SQL Server?

I would like to have emails that are sent to a specific email address, e.g. help@mycompany.com, to be imported into SQL Server via a stored procedure.

I did some research and it appears that I either script for every single message on Exchange, or I create a database job that uses xp_mail to retrieve the mail.

Any ideas and code?
UnionblitzAsked:
Who is Participating?
 
Britt ThompsonConnect With a Mentor Sr. Systems EngineerCommented:
You shouldn't need to use Outlook since you can take the mail directly from the Exchange server while still allowing people to read the mail from Outlook.

Event Sinks: @http://www.eggheadcafe.com/forumarchives/Exchange2000development/Sep2005/post23590076.asp
"you might want to look at using Event sinks. An Event sink can be setup to fire when a new mail arrives and you can then use ADO/Exoledb to access that data and ship it off to your SQL server."

Exchange SDK: http://msdn.microsoft.com/exchange 
http://gsexdev.blogspot.com/2005/07/shared-mailbox-database-public-folder.html

Other than the Exchange part of this it's beyond my scope...try the recommendations from dnilson.
0
 
Britt ThompsonSr. Systems EngineerCommented:
It's very easy to have Exchange forward emails to a specific email address...is this all the email going to exchange or just a single email address that needs to be forwarded to the SQL server?

If it's all the mail to the server you can enable Journaling and forward all the mail from the journal user to the SQL server email : http://technet.microsoft.com/en-us/library/bb124786(EXCHG.65).aspx

To forward email from Exchange 2003 right click on the User in AD > properties > Exchange General tab > Delivery Options > forward to > select the Contact email address to forward to

To forward email from Exchange 2007 right click on the User in Exchange Management Console > properties > Mail Flow Settings tab > Delivery Options > Properties > forward to > select the Contact email address to forward to

If you're needing to pull the mail from the SQL server the Journaling option in Exchange may still play a part...it's pretty heavy on the server depending on the kind of email traffic it has though. If forwarding it from the journal mailbox I wouldn't keep a copy on the server...the mailbox will get unmanageably large.
0
 
UnionblitzAuthor Commented:
Actually, what I want:

1. someone sends an email to help@mycompany.com.
2. SQL Server should some be able to read the new email for help@mycompany.com.
3. SQL Server runs a stored procedure to insert that email into the database.

The only way I can figure this out at the moment is to create an executable in C# that uses Outlook to access the email profile/items, then run a Windows Job against that executable every 10-15 minutes.  This seems grossly inefficient though.

Thoughts?
0
 
dnilsonCommented:
TRy

email2DB
http://www.email2db.com/?source=adwords

AN POP
http://216.240.159.81/titles/parse-email.htm

SQL built in command xp_readmail - a tutorail
http://www.informit.com/guides/content.aspx?g=sqlserver&seqNum=31

Addin Express emulates outlook to SQL interfaces
http://www.add-in-express.com/



0
 
UnionblitzAuthor Commented:
Thank you all for your comments.  This one appears to be the most economical, and it hit the issue right on the head.  Going through Event Sinks appears to be a direct way to stream the emails into the database.  Now I need to figure out how to set up an event sink and write some code for it to execute.  The solution did provide some code, so I might not even need to do that much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.