Sending Base64 encoded email from Airmail to DTTG

DevonThink-to-go has the ability to create a new document through Base64 encoding. While this is useful for images I thought that it would also be useful for archiving properly formatted emails from Airmail. While I have previously documented [url]Airmail to DTTG using new URL scheme] how to archive an HTML formatted email into DTTG there are couple of faults with this. The first is that the email that is created appears as an HTML file in DTTG (rather than an email) and secondly the link that is created is not accessed through a URL in the information button in DTTG. In order to get DTTG to recognise that a file is in fact an email there needs to be a UTI associated with the file. For emails the UTI is Another requirement is header information i.e.

MIME-Version: 1.0  
Content-Type: text/html; charset="iso-8859-1"  

The base 64 URL scheme for DTTG allows us to create a document in DTTG with header information, an HTML formatted body and a UTI that enables DTTG to recognise the document as an email. There are two steps to this process. The first is to create a custom action in AirMail, that points to a workflow in, and has ‘Sender’, ‘To’, ‘Subject’, ‘Html’ and ‘Message link’ turned on. In addition add ‘separator’ as the custom separator and have ‘AirMail callback’ as the output. In other words the custom action should look like this:

The second step is to create a workflow in, called by the custom action in AirMail, (that separates out the variables, adds header information and the HTML body of the email derived from the variables, then base 64 encodes the resulting text and finally uses that data to trigger the following URL:

x-devonthink://x-callback-url/createdocument?title=[url encoded title]&source=[Base 64 encoded text]&[url encoded link]&x-success=airmail://  

The complete workflow is available here: