Just a quick question on whether something is possible to do.

Database: MSSQL

We have a customer that we generate emails for based on sales (e.g. Sales Person X sold Y amount of stock). Against these orders the main system generates a PDF stored as a VARBINARY field in a table.

Is it possible for this VARBINARY to be converted into a physical file (as an attachment or similar) within an email?

I have done similar things with images stored in the database but that is a a lot different than PDF.

This is a Third party application i'm working with so I can't make changes their system.

Thanks for Reading, Joshua

  • Could you convert and save it as .pdf?
    – McNets
    Mar 8, 2017 at 16:55
  • Joshua, were you able to get this working using the same method that worked for images? May 1, 2018 at 15:46
  • Unfortunately not, we abandoned it not long after actually, it wasn't a necessary feature the customer 'needed' to have, there were more secure ways to get the PDFs. I need to find some time one day to actually get this working. I'll mark this as answered for now. Thanks May 3, 2018 at 12:48
  • @JoshuaSmith Ok. And thanks :). If / when you get time to work on it, leave a comment on my answer if you can't get it working. That way I will get notified (or leave a comment here but be sure to include my @ name in the comment so that I get notified of the message). May 3, 2018 at 13:11

1 Answer 1


I have done similar things with images stored in the database but that is a a lot different than PDF.

Actually, for this type of operation, there is no difference between images, PDF, or anything. If you have a binary representation of a file and can save it to disk, then that will work for all file types. Bytes are bytes, and as long as the same bytes are written in the same sequence that they were read in (written as binary, not text), then it doesn't matter what those bytes end up being, even if it is a plain text file or image or DLL or mp3, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.