I’m a library junkie and I would like to make a automation to add books that i’ve lended from the library to Things so I know when to return them.
First question, is there any way to read the body of an e-mail in shortcuts on iOS? I tried the personal automation but I don’t think it actually returns the body of the e-mail, it just works as a trigger. Is there any other way?
The e-mail looks like the code below, sometimes with different amounts of books.
My thought is to select that text and run a shortcut and through that select the title and date (with regex maybe?) for each book and use that info to add a todo in Things.
I have no clue how to use regex though, been experimenting with different editors but it’s quite hard. Anyone has any other ideas on how to do this?
Titel: Cramby, Jonas, Mackor
Titel: Lindeberg, Daniel, Bullar
Titel: Lomelino, Linda, Lomelinos pajer
Yes, you can access the subject and the contents of an email in an email automation. The “Shortcut Input” variable will be an .html (or maybe .txt) file. Its name will be the subject and its contents the contents of the email that triggered the automation.
And yes, regular expressions are the most straightforward way to extract the information you want. For example, try running this shortcut when you receive an email with book information:
Yes. If you use automation, you can use shortcut input as a variable and that will contain the email information. If you don’t wanna do it via an email automation, you will need to copy the text and run a shortcut on that. I don’t know if there is an action that can find a specific email.
You could create a shortcut that does regex but I suck at regex too. So another way would be split text by ‘Titel:’ first and then using a repeat with each action and find dates action to extract the date for each of the items separately. I created one that send the books to Apple Reminders but it should be simple to replace the last action with a things action instead.
Here is a shortcut that uses Regex to select the proper book information.
I don’t use the Things app so for now the shortcut directs the output to a Reminder.
Hi, thank you for your input.
I find it that this shortcut just deletes the row with the id number. I’d like it to select only the title (not the actual “title” and writer. And then also only the actual date.
Here is an updated shortcut.
Edit: I did create an Automation to feed the body of an email to my shortcut however I can’t make a copy of an Automation and send you the link.
Here is how to create your own Automation.
- create a new Automation for “when I get an Email…”.
- Provide a Sender and/or Subject.
- Select Run Immediately option (IMPORTANT).
- click Next to get to the next screen.
- click New Blank Automation.
- on next screen click Add Action.
- in search box type Run Shortcut/then select it.
- in Run Shortcut action press Shortcut and
supply the shortcut name from the list
(Book Info 2.0).
- within the Run Shortcut action press > and add
Shortcut Input to the input parameter (this will “pass” the email text from the Automation to the Shortcut).
- Automation is complete/press Done.
if used, the trigger for selecting the email is something in the SUBJECT line (see #2 above) of the email and NOT in the body of the email.
if you use my shortcut you must first modify the shortcut by using Shortcut Input (the text of the email from the Automation) instead of the current Text info (which I had used for testing purposes).
Hope this helps.