Export CRM annotation attachments as files using classic VB
Posted on 2014-07-18
I am preparing to receive data extracted from a Microsoft CRM database (SQL2008r2) which contains file streams stored as base64 encrypted BLOB data. I haven't had to work with BLOBs before and need to find a simple way to extract these to files. I'm mostly a MSSQL developer (so T-SQL) with VBA/vbscript and some classic ASP experience.
The few code samples I've been able to find are from .Net thin clients, and focus on loading individual attachments to a web page. What I need to do is extract all of the BLOB fields directly to document files.
The pertinent fields are:
I was able to get a small sample of this table to work with, which does not contain all the mime types in the database, but it's enough to get started with. I don't know if the mime type is important if I have the filename with correct extension, but here are the types in my sample:
Since I'm under a time constraint, experimentation with .Net/aspx is not really feasible. I'm also somewhat more confused by the fact that typically BLOBs are stored in varbinary fields and in CRM they are stored as varchar(max). Since most of the examples I can find for dealing with base64 encoding deal with binary data, translating that to the CRM situation presents another challenge.
If you have experience with CRM data and converting/exporting CRM attachments to files, I'd really appreciate your insights.
Thanks in advance!