[MlMt] automatically handle attachments

Thomas Koch thomas.koch at acm.org
Thu Dec 5 09:37:16 EST 2013


Hi,

because I exchanged some pm with Benny about this a short update about 
this and a last open question only side. To explain the context, the 
idea is to make this a part of my paperless workflow, which is heavily 
based on automation, so saving certain attachments is a nice addition to 
this.


On 29 Nov 2013, at 23:51, Benny Kjær Nielsen wrote:

>
> First, I assume you have a mailbox of incoming messages. We'll name it 
> Incoming. Now, create a smart mailbox as follows:
>
> 	Mailboxes: “All Messages” ▸ “All Body Parts”
>
> 	Condition: “Root Body Part” is in “Incoming” “Body Part 
> Id”
>
> This smart mailbox is going to contain any body parts in any messages 
> in the “Incoming” mailbox. Next you can create rules for this 
> smart mailbox. For example:

This works like a blast, so I set up a mailbox filtering wall the mails 
which should be considered for automatic processing. Benny's rule splits 
those messages in the body parts, which is needed to identify the 
attachments properly.

>
> 	Condition: “Content-Type ▸ Type” is “image”
> 	Action: “Run Script” “My Saver”

this worked after i got my bundle correct with help.

> The last piece of the puzzle is the script. You need a bundle for that 
> and those are currently non-trivial to create. You should find an 
> existing one and replace all the UUID values with new values. All you 
> need is a single file in the “Commands” folder which should have 
> content similar to this:

Make sure, that every file in the bundle (here info.plist and the 
Command file) have unique (=different) uuid. I misinterpreted the uuid 
as a "bundle" identifier, but every file needs a different one, these is 
sort of index of all the various parts in the system.

> 	{
> 		name    = 'My Saver';
> 		input   = 'decoded';
> 		script  = '#!/bin/bash\ncat > /tmp/image.png\n';
> 		uuid = '88A186D7-1452-4857-941D-DA96E612F835';
> 	}
>
> This command tells MailMate to provide a decoded body part (binary 
> image data in this case) to the script. The script simply pipes the 
> input to a temporary file.
>
> This should be improved to use a non-hardcoded filename. It could be 
> based on message headers, but this can be non-trivial and I think it 
> would be better if MailMate provided a useful filename (based on the 
> headers). I'll put that on the ToDo. Even better, MailMate should 
> (also) provide a simple “Save” action with a folder location 
> argument to avoid creating a command (and bundle) at all. This could 
> also ensure a unique filename. Until that is available then you could 
> do the following in the command given above:
>
> 	environment   = 
> 'MY_FILENAME=${content-disposition.parameter.split.filename:${content-type.parameter.split.name}}\n';
> 	script  = '#!/bin/bash\ncat > "/tmp/${MY_FILENAME}"\n';
>
> That'll probably work well most of the time.

it does. I am able to save .pdf from various (but controlled) sources 
automatically to my paperless work folder, where the same automation by 
Hazel applies, that is working for scanned documents etc. Exiting!

One last question: I am not able to perform more actions than running 
the saver script, like setting a tag, so


  	Condition: “Content-Type ▸ Type” is “image”
  	Action: “Run Script” “My Saver”
              “set tag” “saved”
              “move to mailbox” “Archive”

just runs the script, but tag setting or moving does not work. Same 
behavior when I set the tag action alone, nothing happens?

Regards

             Thomas


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20131205/f258f415/attachment.html>


More information about the mailmate mailing list