Mail to TP3 script?

This is great thank you @complexpoint

I am new to TaskPaper and not a scripter so forgive me if this is very basic but after trying myself I am unable to achieve the desired modification.

By default this script produces the output:

o [sender name] [sender email] [subject] [recievedTAG(date-time)]
o [outlook link]

It really bugs me that the outlook link is on a new line and not just at the end of the original one. :slight_smile:

o [sender name] [sender email] [subject] [recievedTAG(date-time)] [outlook link]

any help on how to correct this behaviour would be greatly appreciated.


Instead of adding the as a child of the main entry, you can append it directly:

        outline.groupUndoAndChanges(function () {
                .forEach(function (msg) {
                    var item = outline.createItem(
                        '- ' + [msg.sender, msg.subject]
                        .join(' ') +
                        ' @received(' + msg.received + ') ' +

                    // item.appendChildren(
                    //     outline.createItem(
                    // );

1 Like

Thank you good Sir, much appreciated. I was digging in the wrong bit of code! Seems obvious now, clearly forgotten most of what I taught myself many moons ago.

1 Like

Can anyone figure out what I’m doing wrong here (using Apple Mail).
I go into mail and highlight a message
I run the script and it stops on line: var tp3 = Application("com.hogbaysoftware.TaskPaper3”), with Error -2700
I dialogue box appears in mail which says: "TaskPaper got an error: Can’t make class «class TPer».
com.hogbaysoftware.TaskPaper3, as well as, exist, they are in my Application Scripts folder.

Any ideas what I’m doing wrong?

Just a change in the Application id, I think.

If you look for the following in the script:

var tp3 = Application("com.hogbaysoftware.TaskPaper3")

you can edit it to:

var tp3 = Application("TaskPaper")

I’ve made the change, the script runs. So does the moveProject script. Thanks so much for your speedy reply/help.

This is fantastic, @complexpoint, thanks very much for doing this, it works great for me.

Out of curiosity, do you have any sense how hard it would be to convert the script to work with Thunderbird? It’s my preferred mail client, and I’d love the ability to have this there. I suspect this only works with applications that have a callback url scheme defined, but I’m not sure if that’s a blessing from Apple or if developers can just do that.

Thanks again!

how can I activate a TP3 file to add (default file in general). if the file is not in the front and opened, the script does not add items to inbox.

There might be better ways, but here’s one way to open a document from the Desktop and make it the current document. Should work in both cases where document is not yet opened, or when it is already open, but just not frontmost:


Great thanks it worked (I commented the activate since it brings the window in the front)

can I get some help on how to add items to the top of the document rather than at the bottom?

This is in the context of sending to an Inbox project, or perhaps to a project selected from a menu ?

Or just to the top/bottom of the whole document outside a project ?

Could you post the draft you are using at the moment ?

I am trying to get some updates and add them to a current open file. There is no inbox or project yet. I am trying to use various Taskpaper files inside Devonthink and use them to manage individually rather than one big doc

Current all the updates go with the script to the bottom on the document where as I want to view the most recent updates on the top.


Here is a (Sierra onwards) snippet which adds three lines of text (from an options array at the foot of the script), to the start of the open document.

Is that the pattern that you need ?

(options => {
    'use strict';

    // TASKPAPER 3 CONTEXT ---------------------------------------------------
    const taskpaperContext = (editor, options) => {
        const outline = editor.outline;

        outline.groupUndoAndChanges(() =>
                .map(x => outline.createItem(x)),

    // JXA CONTEXT------------------------------------------------------------

    // Just :: a -> Just a
    const Just = x => ({
        type: 'Maybe',
        Nothing: false,
        Just: x

    // Nothing :: () -> Nothing
    const Nothing = () => ({
        type: 'Maybe',
        Nothing: true,

    // bindMay (>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b
    const bindMay = (mb, mf) =>
        mb.Nothing ? mb : mf(mb.Just);

    const ds = Application('TaskPaper')
    return bindMay(
        ds.length > 0 ? Just( : Nothing(),
        d => d.evaluate({
            script: taskpaperContext.toString(),
            withOptions: options
    itemsToAdd: [

thanks a lot sincerely appreciate it. Let me try and get back to you.
thanks again!

yes works great in that order (which are in chronological order when I add ie the latest goes to the top)
eg. on an email thread I want to capture various emails (only relevant ones) and keep filing them into a Taskpaper doc

msg-c (today)
msg-b (2 days go)
msg-a (3 days ago)


thanks again