C-Command Software Forum

Applescript to pipe emails into EF

Before I begin to overhaul my entire workflow, I figured I would ask a question here first.

I currently have a Mail.app rule setup to pipe emails sent to a specific email address to Yojimbo using applescript.

Is something like this possible with EF. I searched around on the interwebs for a bit, but didn’t see anything that jumped out at me and I am not proficient enough to attempt developing a solution myself.

Any help would be appreciated.

I don’t see why not. You can import text into EagleFiler like this:

tell application "EagleFiler"
    tell library document 1
        import plain text "this is a test"
    end tell
end tell

so it should be easy to adapt your existing script. However, this would not take advantage of EagleFiler’s special support for mail (smarter display, efficient storage, and specialized searching); it simply imports a text file (or RTF file if you use “import text”). To import mail as mail, it would be better to select a mailbox in Mail and press the capture key.

Thanks for the info. I really don’t need a lot of special formatting. It’s basically an email address I send notes to from my iphone while out and about that get processed automatically for later attention.

With that said, is there anyway to invoke the capture key or services menu item via applescript?

In that case, importing as text is probably better.

Yes, but that doesn’t really make sense. Those both act on what you’ve selected in the user interface. For an automated solution (e.g. using a Mail rule) you need to work with the message that the rule is processing, so it’s better to use the import script command (as above).

Thanks again. I’ll work with that and see how it turns out.

I have a case where I think a script to invoke the capture command does make sense. I use Mail Act-On in Mail, and I have an Act-On rule that moves selected e-mails to my “Receipts and Accounts” mail folder. It would be handy if I could invoke the capture key in that same rule. That way I only have to perform one set of key strokes on those messages.

But at the moment i don’t know how to go about doing this. I know very little about Applescript.

One question in that regard, though. Is it possible to specify which Library the selected mail messages are to be filed in? I currently have three libraries, and I want to make sure they go to the right one.

kabing

You can use AppleScript to simulate pressing the capture key:

tell application "System Events"
    key code 122 -- F1
end tell

(If you’re not using F1, you can look up other keycodes here.)

You could use the capture with options key:

tell application "System Events"
    key code 122 using {option down} -- Option-F1
end tell

Or, with a regular AppleScript, you would specify the library by putting the import command inside a tell for that library.

My you are fast to respond! Thank you! I just came back to tell you I’d found an answer–sort of.

I’m evaluating Together at the same time I’m testing EagleFiler, and I checked their forums for the same thing. Someone there had suggested the key code applescript in an earlier thread, and I realized that it would work for EagleFIler, too.

The only problem I have is that I get a mail error because Mail is also moving messages as part of the same rule. So unless there’s a solution I don’t know about, it would appear I’m back to moving and importing the e-mails separately. Hardly the end of the world.

By the way, thank you very much for the list of key codes. I have no doubt that will come in handy at other times.

kabing

Yeah, it’s not a good idea to use the capture key when Mail’s underlying message files are in flux. In this case, I would suggest using a script that asks Mail for the source of the message, writes it to a temporary .eml file, and then imports that file into EagleFiler using the normal AppleScript commands.

I’m afraid that solution is beyond my Apple Script abilities. I’ll just have to be content with two separate actions.

Thanks again. I’m enjoying getting to know EagleFiler

kabing

I’ve written a script that shows how to do this.

Sweet! It works like a charm!

Given that I have more than one library, is there anyway to modify the script so I get asked which library?

Do you want to be asked each time? Or choose the library now and bake that into the script?

In my particular case, having it “baked” in the script would work fine, as I’m using it in a set of rules that apply to messages which go all to the same library.

kabing

OK, you can just change where it says:

import files _paths

to something like:

tell library document "MyLibrary.eflibrary" to import files _paths

Thank you very much! That has greatly simplified organizing my mail!

kabing

As of EagleFiler 1.5, the scripting dictionary has a command to initiate a capture.