I actually can use the mail app too, however I cant figure out in the shortcut how to actually choose the mailbox (I have multiple accounts set up with it) I want it to pull the emails from… haven’t gotten to far yet but this is what I have so far…
Ideally it would show the list of all the emails, can choose the email I was to create a task for, it would then prompt for the due date, and then create the task on my daily note with the due date, and archive the email
If you’re fine with working in Apple’s Mail.app, I can do you one better. Here’s an example workflow which extracts sender, subject and the mail’s internal link for use in Shortcuts:
The workflow uses Applescript for extracting the info, then turns its result into a dictionary (using the built-in Get Dictionary from Input action), which allows you to use the dictionaries mailSender, mailSubject and mailLink keys further down the line – for example when creating a new Obsidian note or task.
Hi, @czottmann and @ethanopp I adapted the AppleScript for Outlook. But this only works when the Outlook App is running in the “legacy mode”. Because Outlook covers mail, contacts, task the Outlook AppleScript function library is a little bit more complex that the one of Apple Mail (s. screenshot below), but it’s hard to find good examples and I’m not an Apple Script expert, so I can’t give more advise .
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on run
tell application "Microsoft Outlook"
if not it is running then activate
set selectedMessages to current messages
if selectedMessages is not {} then
set msg to item 1 of selectedMessages
else
return
end if
tell msg
set mailSender to its sender
set mailSubject to its subject
set messageId to id of item 1 of selectedMessages
set uri to "outlook://" & messageId
return {mailSender:mailSender, mailSubject:mailSubject, mailLink:uri}
end tell
end tell
end run
II run both scripts on Outlook and Mail and both work with multiple accounts. It just takes the selected item and prints some information. Nothing more, nothing less. BTW: The URI part of the Outlook script is useless. It needs some more research.
I added two scripts here that list all accounts by name, which might be useful if you only want to look into your private gmail account. I think you can do a lot with AppleScript in both mail applications, but from my non-expert perspective, it might not be easy.
Regards, Leif
tell application "Microsoft Outlook"
set theAccounts to get imap accounts
set ExchangeAccounts to get exchange accounts
set theAccounts to theAccounts & ExchangeAccounts
set accountInfo to {}
repeat with theAccount in theAccounts
set end of accountInfo to "Name: " & name of theAccount
set end of accountInfo to "Username: " & user name of theAccount
end repeat
return accountInfo
end tell
tell application "Mail"
set theAccounts to get accounts
set AccountInfo to {}
repeat with theAccount in theAccounts
set theAccount to {name of theAccount & "---" & user name of theAccount & "---" & server name of theAccount & "---" & port of theAccount}
set end of AccountInfo to theAccount
end repeat
return AccountInfo
end tell
For example in my mail app and outlook app, I have my company email and my personal Gmail both connected, how do I just parse my company emails?
The workflow uses the selected mail, or, if there is more than one selected mail, the first of those. It doesn’t care about which account the mail belongs to, and the link it returns should make Mail.app retrieve the mail from any account it knows.