Can’t make new reminder in Mail Rule

Hi,

Try this routine, it’s pretty much the same except I specify the rule that is being triggered and added a routine to create the Reminders list if it doesn’t exist.

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}
		end if
		
		return make new reminder ¬
			with properties {name:reminderName, body:reminderBody, due date:reminderDueDate} ¬
			at list reminderListName
		
		return missing value
	end tell
end createReminder

Cheers

Iain

2 Likes