Decoding AMS messages outside of Ability Mail Server
Posted: Fri Jun 03, 2011 8:12 pm
I have written several applications that process emails sent through AMS, including those with attachments. I am aware that I can use AMS rules to extract attachments and write other data to a text file upon receipt of the email (and that's what I am doing now), but I would like to be able to re-process already-received emails without manually forwarding them again through AMS.
"Raw" AMS emails including attachments are stored as ASCII text files in the user's Inbox or other folder. I can programmatically iterate through a user's Inbox and extract base64 attachments by parsing the text files, isolating the base64-encoded data and passing it through a decoding function. However, I am having trouble with a few emails that seemingly encode the subject and attachment names (among other data) in utf-8.
For example, in one email, in the raw AMS text file in the user's Inbox the email subject appears as:
"Subject: =?utf-8?B?QkkzNDM3LzE2?="
The decoded subject when viewed in AMS webmail is BI3437/16.
The data preceding one of the attachments is:
------=_Part_2_1302042315289
Content-Type: image/jpeg;
name="=?utf-8?B?SU1BRzA0NTYuanBn?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="=?utf-8?B?SU1BRzA0NTYuanBn?="
The decoded attachment filename is IMAG0456.jpg
I have tried experimenting with online decoders without any luck just to see if I can get the data decoded. I primarily use Excel VBA or Visual Foxpro 9.0. I'm wondering if you have any links or other ideas that can point me in the right direction.
"Raw" AMS emails including attachments are stored as ASCII text files in the user's Inbox or other folder. I can programmatically iterate through a user's Inbox and extract base64 attachments by parsing the text files, isolating the base64-encoded data and passing it through a decoding function. However, I am having trouble with a few emails that seemingly encode the subject and attachment names (among other data) in utf-8.
For example, in one email, in the raw AMS text file in the user's Inbox the email subject appears as:
"Subject: =?utf-8?B?QkkzNDM3LzE2?="
The decoded subject when viewed in AMS webmail is BI3437/16.
The data preceding one of the attachments is:
------=_Part_2_1302042315289
Content-Type: image/jpeg;
name="=?utf-8?B?SU1BRzA0NTYuanBn?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="=?utf-8?B?SU1BRzA0NTYuanBn?="
The decoded attachment filename is IMAG0456.jpg
I have tried experimenting with online decoders without any luck just to see if I can get the data decoded. I primarily use Excel VBA or Visual Foxpro 9.0. I'm wondering if you have any links or other ideas that can point me in the right direction.