Using Airmail’s integration with Workflow to get a more portable message link.
The number of email clients on iOS is no small thing, and it continues to grow as developers implement their own ideas on how to improve email. Each of these have their strengths and weaknesses and those can vary widely between some email apps. It’s undeniable that one of the biggest players in this space right now is Airmail (also available on macOS).
Airmail is an email client geared towards power users, providing users with numerous options for taking action on email messages. This includes the now-typical options to snooze a message or mark it as a todo, as well as a long list of actions to process messages with system features or send them to a number of apps. With Airmail’s actions, you can easily create a reminder, an event, or a PDF, or send the email message to one of the supported apps such as Trello, OmniFocus, Todoist, Day One, Ulysses, Bear, and even DEVONthink, just to name a few.
A more recent addition to Airmail actions is support for running workflows in Workflow and custom actions. Custom actions can be useful, allowing you to essentially carry out multiple actions in one. With custom actions, you can star an email and then create a task or reminder, without having to run two separate actions. Workflow actions are setup as custom actions as well.
When setting up a Workflow action, you can choose which elements of the message are sent to the workflow such as Sender, Sender name, To, CC, HTML, Text, and more. It also offers the Message Link parameter, however message links are created as
airmail:// URLs, which means you can only open them in Airmail. While there are advantages to this, if I am linking to a message in a note or some reference material that I may come back to down the road, I want to be able to open that message even if I am using a different client. That’s where Workflow comes in. Apple Mail also has a URL scheme that allows you to open messages from elsewhere. The messages have a unique message ID. This ID is the same in Mail as it is in Airmail and this is what is required for Mail’s URL scheme to open the right message.
Mail’s URL scheme to open a particular message is
message://<messageid>. We can set up the action in Airmail to send the message link to the workflow, and then we can use Workflow’s Match Text and Get Group from Matched Text actions to isolate the message ID from the Airmail URL that is sent to the workflow. We can do this using a simple regular expression
messageid\=(.+)$ to match the ID and then insert the group we get from into a
message:// URL within a Text action.
I should back up a moment and add that sometimes, I want a link in a markdown format. I setup my Airmail action to send the Subject in addition to the link. When setting up Workflow actions that send multiple parameters, Airmail lets you define a custom separator character. At the beginning of the workflow, you can use the Split Text action to separate by the same custom character you set in the Airmail action. The you can reference each item individually at its index using the Get Item from List action. This allows us to receive the link and the subject, and then provide multiple options for generating the link as a plain URL, or a markdown link. I took it a step further in my workflow by including the option to generate an Airmail markdown link or a plain Airmail link as well.
Now whether I need to reference an original message source months from now, or just create a quick reminder with the link to a message, I’m good to go. You can get the workflow here.
EDIT: Somehow a couple of little things got changed that I didn’t realize before. The proper changes have been fixed in the version of the workflow linked above, so that shouldn’t be an issue. Just pointing out that the screenshots throughout this post may show a few differences. In setting up the Airmail custom workflow action, the separator field should not be blank, it should be a double pipe
|| character. I also changed the index in the workflow from what the screenshot shows. For some reason if a separator is specified in Airmail, the app will include a blank item first, so the subject was at Index 2, rather than Index 1. Finally, I added a copy option to the workflow, which was also not pictured. Apologies for any confusion. Hope you find this workflow useful.
Note: Airmail and Workflow icons are property of their developers/owners/designers, which is not me