I’m looking for an easy way that doesn’t involve using something like Indy to just decode Base64 that contains what the message from Thunderbird said.
Example:
WW91ciBtZXNzYWdlDQoNCiAgVG86ICAgICAgeHh4QHh4eC5jb20NCiAgU3ViamVjdDogSXh4eA0KICBTZW50OiAgICBUaHUsIDIyIE9jdCAyMDA5IDAxOjE0OjM0IC0wNDAwDQoNCmRpZCBub3QgcmVhY2ggdGhlIGZvbGxvd2luZyByZWNpcGllbnQocyk6DQoNCnh4eEBneHh4IG9uIFR1ZSwgMjcgT2N0IDIwMDkgMDE6NDA6NDQgLTA0MDANCiAgICBUaGUgZS1tYWlsIHN5c3RlbSB3YXMgdW5hYmxlIHRvIGRlbGl2ZXIgdGhlIG1lc3NhZ2UsIGJ1dCBkaWQgbm90DQpyZXBvcnQgYSBzcGVjaWZpYyByZWFzb24uICBDaGVjayB0aGUgYWRkcmVzcyBhbmQgdHJ5IGFnYWluLiAgSWYgaXQgc3RpbGwNCmZhaWxzLCBjb250YWN0IHlvdXIgc3lzdGVtIGFkbWluaXN0cmF0b3IuDQogICAgPCBDaW54eHguY29tICM1LjAuMCBzbXRwOyA1LjQuNyAtIERlbGl2ZXJ5IGV4cGlyZWQNCihtZXNzYWdlIHRvbyBvbGQpICd0aW1lb3V0JyAoZGVsaXZlcnkgYXR0ZW1wdHM6IDApPg==
Becomes:
Your message
To: xxx@xxx.com
Subject: Ixxx
Sent: Thu, 22 Oct 2009 01:14:34 -0400
did not reach the following recipient(s):
xxx@gxxx on Tue, 27 Oct 2009 01:40:44 -0400
The e-mail system was unable to deliver the message, but did not
report a specific reason. Check the address and try again. If it still
fails, contact your system administrator.
< Cinxxx.com #5.0.0 smtp; 5.4.7 - Delivery expired
(message too old) 'timeout' (delivery attempts: 0)>
Edit: Seems that the max length a MIME Base64 line can be is 76. I have to decode each 76 bit long line, not the entire message at once. Thanks.
The decoding isn’t that hard to code up, but here’s a blog with some sample code for Delphi
http://www.delphifaq.net/how-to-base-64-mime-encode-and-decode-a-string/
The basic idea is that there are 64 characters, each represent a bit pattern for 6 bits. You turn the character back to its 6 bits with a table look-up, and then you take your list of bits, and break them back into 8-bit chunks to make bytes.