Skip navigation

I have found myself in several situations where I have needed to take a binary file and encode it for some sort of data transmission (over HTTP, XML, WebDAV, EDI, etc).

While having an encoder COM component is nice, its can be expensive to find one that utilizes all "standard" modes of encoding (UUENCODE, BASE64, 7 Bit, 8 Bit, etc)

Well, a cheap way to do this is using the CDO.Message interface with ADO.

Since CDO is based on Internet internet standards (SMTP, MIME, etc), it utilizes all the "standard" methods for encoding messages and attachments for mail delivery.

To encode a file, all you need is to create an instance of a Message. Attach a file to that message. Then set an ADO stream to the bodypart of your message. Finally you can read the "encoded" string for your message right from the ADO stream object.

To unencode it, all you need to do is reverse the method described above.

You can simply change the "encoding" method by changing the Now, this may not be the most efficient method for data encoding and this method has not been tested for scalablity. But if you need a cheap quick and dirty method for binary encoding, CDO is the best method I have found.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish