Applying a shortcut script to a mail message?

I have a series of customer support AppleScripts that create entries in our Script Debugger issues database from an email message. I want to move these workflows to my iPad. I’ve done some Googling looking for a means of applying a Shortcuts script to an email message on my iPad without much success. I cannot see how to share an email message to a Shortcuts workflow. Does anyone know of a good way of doing this?

In my opinion: No chance!
Somehow Apple has forgotten the Share menu in Mails.

The only thing you can do is select text and share it (also to a Shortcuts workflow). However, you will not receive a link to the e-mail within the shortcut. But Apple itself works with references when sharing. For example, mark the subject of an email and share it with the Reminders app. Apple creates a reminder including an email icon as a link.

However, the link is not read or editable in any way (in earlier versions it was still stored in the url field in the format “message:…”).

Since the introduction of shortcuts, automation is getting worse and worse. In my view, this is more of a gimmick than a serious workflow tool. It doesn’t even recognize e-mails as an input format. Unfortunately, more and more developers are supporting it instead of implementing an Apple Script Dictionary.

Addition:

You may have a chance with your own iOS / iPadOS app that receives text and can then be accessed via the Share menu. Maybe you can access the e-mail information, as Apple does internally. However, I have not yet tested whether and what is actually transferred.

Thanks for confirming my impression of things and giving me the Drag and Drop idea.

I’ve experimented a bit using Drag and Drop to pass an email from Mail to another app and it works well. Dragging and dropping an email message allows me to get the entire email in MIME format which I can parse. I can package this up as a JSON dictionary and pass that as text to a Shortcuts workflow which then uses the Get Dictionary from action to pull it all apart for use.

Here’s my shortcut script which displays the message subject an body:

And here’s how it all operates:

Is this a thing anyone else would find useful? If so I can file off some of the rough edges and put it up on TestFlight so we can improve it. I presume someone else has already done this, and better, but I cannot find anything.

Here’s the code on GitHub for those that want to play with it.

2 Likes

Great idea with the drag & drop! :wave:

However, there definitely seems to be no way around a separate app, as shortcuts do not accept emails as input. Interestingly, emails are sometimes listed as input in Action


How to get the email into the shortcut, however, remains Apple’s secret.

For me, all this doesn’t seem to be fully developed yet and I only use shortcuts when there is really no other way, like with iOS / iPad or there is no Apple Script Dictionary:
Example of passing parameters to a Shortcut and getting the return

I don’t have an iOS device, but it’s a bit surprising to me that some apps have a large number macOS Shortcuts actions but Mail only has four. The macOS Shortcuts app is not yet three years old, and I assume that additional Mail actions will be added in the future. However, I agree with Dirk that the Shortcuts app needs a lot of work.

I had a couple thoughts, neither of which seems to pan out, but I thought I’d share them in case they spark other ideas:

  1. Siri has a notion of “this”. For example you can say “remind me of this” while looking at an email message and it will add a Reminder with a link to the mail message. I was hoping that the “this” would correlate directly with Shortcuts ability to “Receive What’s on Screen”, but it doesn’t seem to include the mail message even when I create a new Shortcut called “Perform Magic” and then invoke it in Mail by saying “Perform Magic this”.

  2. Speaking of “remind me of this”, I wonder if Reminders could somehow be a conduit through which your workflow runs? I have previously used Reminders to pipe todo items from my iPhone to OmniFocus running on my Mac: GitHub - danielpunkass/RemindersImport: Command-line tool for migrating Mac OS X Reminders from the canonical system storage to The Omni Group's OmniFocus app.

In fact, the RemindersImport tool above includes code to pull the “appLink” out of a reminder using private SPI, but that doesn’t seem to be working anymore in a test I did just now. Still, once the reminder is in Reminders with the pertinent email linked, it’s possible it could be scavenged somehow by a process running on another Mac.

Daniel