This helper consists of two parts: an AppleScript and a Shortcuts workflow. The AppleScript is a Mail rule that triggers the Shortcuts workflow. The Shortcuts workflow then takes the email and turns it into a note in your Obsidian vault.
This basically adds a “Note to self” ability to your Obsidian vault(s), which uses what you already have and use: your existing email account and macOS.
Good to know:
For obvious reasons, your Mac and the macOS Mail app must be running for this work. (Mail can be in the background, though.)
It makes use of Mail’s rules feature and AppleScript, both of which are not available on iOS — this is a macOS-only workflow.
Download AppleScript “Send Mail to Shortcuts.scpt”. Copy or move the downloaded .scpt file into the folder ~/Library/Application Scripts/com.apple.mail/. (If you have trouble finding that directory: open a Finder window, open the menu entry “Go” → “Go to Folder…” (or press ⇧⌘G), then paste the path ~/Library/Application Scripts/com.apple.mail/ into the following prompt, and hit Enter.)
I like this a lot. But I wonder how it’s possible to specify a specific folder for these e-mail-turned-notes within my vault? Now I can just give the name of my vault, which makes it so that all the e-mails are just sitting there unsorted. I’d rather dump them into an appropriate place.
Yes, it’s possible. See the screenshot in the original post, and check out the very last action, Create Note. In the first parameter, where it reads [Mail subject] (“Mail subject” being a variable), you would change that to My folder/[Mail subject] — i.e., prefix the variable in that parameter field with your folder name, like so:
Thanks for sharing this @czottmann – This is great and not only for a “Note to Self”:
I was looking for a way to build a slim CRM in Obsidian and this looks like one crucial piece to get it done.
Maybe also helpful for others: As Carlo pointed out in the video, you can work other filters too:
So you can specify e.g. that they are in your contacts or in a certain group (and this way you could even run different shortcuts [and saving locations in Obsidian] depending on groups).
Great stuff
I am not sure if something has changed in the Apple Shortcuts. I have tried this on two Macs and the last step of the shortcut to create a new note shows the message “Unknown action - this action could not be found on this version of shortcuts”. I’m running OS15.1.
I have been desperate to get this to work. I had tried a couple of months ago and the shortcut was working, but not working to trigger the obsidian note. An action was being triggered, and a pop up window would ask what vault to put the note in. However, the vault was specified in the shortcut and the pop up window did not provide any options to specify a vault so I had to give up. Coming back to this to spend some more time to get it working showed this new message - weird right?
From what you describe it sounds like AFO doesn’t know about your vaults yet. If this worked before but doesn’t anymore than my guess is that “before” means pre-Release 2024.1 (macOS & iOS) – in this version, the vault handling changed. I think that’s the case because you wrote:
However, the vault was specified in the shortcut and the pop up window did not provide any options to specify a vault so I had to give up.
Just re-run the onboarding (“Link your vault”) for all the vaults you want to use with AFO. Then, check the workflow in the Shortcuts editor again, click the Create Note’s Vault parameter, and at that point you should be able to select any of your linked vaults.
@czottmann I’ve tried several things but how do I get this email note set in a specific folder. In my case it needs to be added to the folder 40. Notes.
You’d prefix the “path” field with /40. Notes/. The Shortcuts editor is quite fiddly when it comes to prefixing, however.
So: click/tap the content of the field (the “Mail subject” variable), clear the field (remove the variable), then type in the folder, followed by “Mail subject”. Shortcuts should recognize you mentioning a named variable, and offer to insert it.
Hi,
Seem to having issues with this one. Followed all the guides, and it works…but instead of the email I’m sending to ‘myself’ appearing in Obsidian, it instead shows a random other email that’s already in my inbox (that doesn’t match the conditions set), and not the one I’ve just sent.
Haven’t amended the Shortcut (apart from the vault name) nor the AppleScript. The rule matches your example except for the ‘To’ email address
Any ideas? Thanks in advance…
but instead of the email I’m sending to ‘myself’ appearing in Obsidian, it instead shows a random other email that’s already in my inbox (that doesn’t match the conditions set), and not the one I’ve just sent.
Hnnnngh, great. The very short answer is: Mail’s not very bright, I guess? The Applescript uses Mail’s own command set, and the line:
on perform mail action with messages filteredMails for rule mailAppRule
… tells Mail to process any mail which fits the filter criteria of the mail rule. If it returns mails which do not fit the filter then that means either that Mail.app is buggy or that the filter rules have a hole.
You can test that by selecting one or two mails in your inbox and triggering the “Apply Mail” entry in Mail’s menu (or hitting CmdOptL).
TBH, I wouldn’t be surprised if any incoming mail would trigger the application of rules, and each rule would then look at the entirety of the inbox instead of just new mail. So just to make sure, I’d add a second action to the “note to self” rule which moves the processed mail either to the trash or another folder.
Hnnnngh indeed Tried the suggestions, and still the same result (except applying the rule to existing emails does work).
I’ve noticed that the mail message that DOES get fed into Obsidian from the rule is one immediately underneath the one I want it to work on. I’ve also emptied the inbox so that when the test message I’m sending arrives, it’s the only one in the inbox: nothing happens then, except the rule is working as such though, as I added a line to colour the message, and it does that.
Strange…