Apple Mail Rule - New Reminder from Email

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:

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!
 
Joined
Feb 14, 2021
Messages
989
Reaction score
131
I don’t understand why you need AppleScript for what you need. Try this.

From Mail, go to Settings. From the settings window, click on Rules. Enter a label for what you are setting up. On the first field, select “From” “contains” and paste in the e-mail address that you want the notification for in the box. You can make it more generic by just using the domain (@xxxx.xxx) if you want notification from anybody from that address.

The next field starts with “Move Message.” Click and hold and select “Send Notification” from the pulldown. Then you will just have to wait for the next e-mail from them to test the rule. I make it more specific by assigning a specific sound for specific senders, instead of a simple notification.
 
Joined
Apr 16, 2023
Messages
2
Reaction score
0
Hi Tony, thanks for your post.

Perhaps my initial post was not clear. I am trying to create a new Reminder in the Apple Reminders app - ie: a task.

I believe what you have posted will only send a notification to the Notification Centre, unless I am mistaken?
 
Joined
Feb 14, 2021
Messages
989
Reaction score
131
Hi Tony, thanks for your post.

Perhaps my initial post was not clear. I am trying to create a new Reminder in the Apple Reminders app - ie: a task.

I believe what you have posted will only send a notification to the Notification Centre, unless I am mistaken?
You’re correct. I misunderstood what you were aiming for. My bad.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top