- Joined
- Apr 16, 2023
- Messages
- 2
- Reaction score
- 0
Hi there, I am trying to create an AppleScript that will create a new Reminder from an email based on an Apple Mail Inbox rule. The rule will be triggered by a specific email address in the To field.
I have two reference websites with some example scripts but I am not sure what I need to change in the provided scripts to make it work on my system. I have tried the first code as-is and nothing happens. I am guessing there is nothing in here to specify which list to create the reminder in. I am happy with the default list if that is my only option.
The first code comes from: https://www.reddit.com/r/applescript/comments/hr9r85 and is as follows:
The second example code comes from: https://talk.automators.fm/t/can-t-make-new-reminder-in-mail-rule/8177/3 but seems to be less dynamic around the subject.
Thank you for any help you can offer!
I have two reference websites with some example scripts but I am not sure what I need to change in the provided scripts to make it work on my system. I have tried the first code as-is and nothing happens. I am guessing there is nothing in here to specify which list to create the reminder in. I am happy with the default list if that is my only option.
The first code comes from: https://www.reddit.com/r/applescript/comments/hr9r85 and is as follows:
AppleScript:
use AppleScript version "2.4"
use scripting additions
using terms from application "Mail"
on perform mail action with messages messageList in mailboxes mbox for rule aRule
repeat with theMessage in messageList
makeReminder((theMessage's subject as string), "List Body", (current date), "List Name")
end repeat
end perform mail action with messages
end using terms from
on makeReminder(reminderName, reminderBody, reminderDueDate, reminderListName)
tell application "Reminders"
if not (exists list reminderListName) then
make new list with properties {name:reminderListName}
end if
set existingReminder to reminders where due date = reminderDueDate and name = reminderName
if existingReminder is {} then
return make new reminder ¬
with properties {name:reminderName, body:reminderBody, due date:reminderDueDate} ¬
at list reminderListName
end if
return missing value
end tell
end makeReminder
The second example code comes from: https://talk.automators.fm/t/can-t-make-new-reminder-in-mail-rule/8177/3 but seems to be less dynamic around the subject.
AppleScript:
use AppleScript version "2.4"
use scripting additions
using terms from application "Mail"
on perform mail action with messages theMessages for rule Test
repeat with msg in theMessages
set remName to "Xfinity bill"
set remNotes to "https://customer.xfinity.com/#/billing"
set remList to "Xfinity"
set msgDate to (get date received of msg)
set remDate to msgDate + 5 * days
set hours of remDate to 10
set minutes of remDate to 0
set seconds of remDate to 0
createReminder(remName, remNotes, remDate, remList)
end repeat
end perform mail action with messages
end using terms from
on createReminder(reminderName, reminderBody, reminderDueDate, reminderListName)
tell application "Reminders"
if not (exists list reminderListName) then
make new list with properties {name:reminderListName}
Thank you for any help you can offer!