Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save logic2design/ccd7820a01c13032e4e3d6240779aad6 to your computer and use it in GitHub Desktop.

Select an option

Save logic2design/ccd7820a01c13032e4e3d6240779aad6 to your computer and use it in GitHub Desktop.
Will check if there is an existing Reminder for the Mail Message, offering to remove the flag if Reminder has been completed
#################################################################################
# Title: Check Mail message Reminder status
#################################################################################
#v1
#Logic2design.com
#logic2design@icloud.com
# Contributors and sources
# http://www.michaelkummer.com
tell application "Mail"
set theSelection to selection
# do nothing if no email is selected in Mail
try
set theMessage to item 1 of theSelection
on error
return
end try
set theSubject to theMessage's subject
tell application "Reminders"
set reminderCompleted to name of reminders whose name is theSubject and completed is true
set reminderOpen to name of reminders whose name is theSubject and completed is false
if reminderCompleted is not {} then
tell me
activate
end tell
set theButton to button returned of (display dialog "The selected email matches a completed reminder, would you like to clear the flag of this message?" with title "Clear Reminder Flag" buttons {"Mark complete", "Cancel"} default button 1)
if theButton is "Mark complete" then
tell application "Mail"
# unflag email/message
set flag index of theMessage to -1
end tell
else if the_button is "Cancel" then
return
end if
else if reminderOpen is not {} then
display dialog "Reminder still active" with title "Reminder Check" buttons {"OK"} default button 1
else
display dialog "No Reminder Found!" with title "Reminder Check" buttons {"OK"} default button 1
end if
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment