We help IT Professionals succeed at work.

How do I have Exchange forward emails to SQL Server?

Medium Priority
592 Views
Last Modified: 2013-11-30
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?
Comment
Watch Question

Britt ThompsonSr. Systems Engineer
Top Expert 2009

Commented:
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.

Author

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?

Commented:
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/



Sr. Systems Engineer
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.