Passing a variable (or clipboard contents) to a callback-url

I have an Applescript which takes the contents of an email in the Mail app - and a direct link to that email and stores all of the info in a variable called theMsg. The Applescript is invoked via a snippet using TypeIt4Me. This all works fine, and when I paste the clipboard content I get exactly what I want.

Now, I would like to then create a note in Agenda using a callback-url which passes the contents of the variable theMsg to the &text part of the callback-url, thus creating a new note with the content of the email, and a link to the email.

I’m using the example here in the documentation:

open location “agenda://x-callback-url/create-note?title=New%20Note&text=theMsg

Obviously that isn’t working as it’s viewed as plain text.

I’m not sure how to append either the contents of the variable theMsg, or simply paste in the contents of the clipboard. Is this possible at all?

Thanks very much in advance.

Gavin

You’ll need to concatenate the variable instead of putting it in the string.

open location “agenda://x-callback-url/create-note?title=New%20Note&text=" & theMsg

Just make sure theMsg is URL encoded too :slight_smile:

1 Like

Thanks for the suggestions - much appreciated

So I finally got this done - Mac only (not iPhone or iPad, but most of my work is done at my desk). To make it work, select an email in the standard Mail app, then run the shortcut.

It’s set up to create a new note in a Project called Inbox (though obviously this would be easy to change). It copies the whole mail into the new note, and creates a link back to the mail (though you need to click next to the link for it to activate - not sure why).

It also adds a reminder at the end if the original email had attachments - just so I know if I need to go back to the email for the full thing.

I’m leaving it here in case someone wants to use/adapt it.

https://www.icloud.com/shortcuts/c16b0ce5044f41fa87a58c2842beab5f

Gavin

1 Like