Decoding AMS messages outside of Ability Mail Server

Decoding AMS messages outside of Ability Mail Server

Postby ehavemann » 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.
ehavemann
 
Posts: 26
Joined: Fri Dec 14, 2007 6:15 pm

Re: Decoding AMS messages outside of Ability Mail Server

Postby Code Crafters » Tue Jun 07, 2011 7:13 pm

If I remember correctly, it's the Content-Transfer-Encoding that tells you what encoding is for the attachments / filename and also for the main subject (there's an encoding in the main header for that).

Content filtering does allow extracting of attachments which will be auto-decoded for you if this helps. You can also use Antivirus Filtering to allow a scan of the email where your application gets to change the file which is then picked back up making your changes remain after filtering.
Code Crafters
 
Posts: 943
Joined: Mon Sep 10, 2007 2:35 pm


Return to General

Who is online

Users browsing this forum: No registered users and 36 guests

cron