Saving Outlook Mail Messages in a Microsoft SQL Server Database

I use C # to write an Outlook 2007 add-in to store emails in a SQL Server 2005 database. I would like to be able to store the entire .msg file in a varbinary(MAX) field. Is there a way to do this without using the Outlook MailItem SaveAs() method to save to a temporary file and then read the file again? I will need to transfer a large number of letters to the database and prefer to avoid expensive reads and writes to disk.

+6
c # sql-server outlook-2007 vsto outlook-addin
source share
2 answers

If you want to save it as a .msg file without trying to rewrite it yourself, I would say that you are looking at the route you were talking about.

Personally, I would go to the storage of bits and parts of the email, but it depends on what you are going to do with it. Storing an MSG file in a database, in my opinion, has nothing of value. Your use case may now be different.

+2
source share

Maybe.

Depending on your installation, you can avoid Outlook and just use Exchange / SQL Server.

Linked server with Exchange.

I have never tried this, so YMMV

+1
source share

All Articles