Last active
April 2, 2020 22:43
-
-
Save nateswart/8328138 to your computer and use it in GitHub Desktop.
Create Reminders tasks from flagged emails in Mail.app on OSX Mavericks using Gmail accounts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
on run | |
-- This script is designed to work with Gmail and OSX Mavericks | |
-- Make sure Mail.app is actually running | |
if not (application "Mail" is running) then | |
return | |
end if | |
-- Make sure Reminders.app is actually running | |
if not (application "Reminders" is running) then | |
return | |
end if | |
-- We'll put a double newline between segments of the message in the notes field | |
set newline to (ASCII character 10) & (ASCII character 10) | |
tell application "Mail" | |
-- Look through all email accounts | |
repeat with _account in imap accounts | |
set _inbox to _account's mailbox "[Gmail]/All Mail" | |
-- Get a list of all flagged messages for this box | |
set _messages to (a reference to (every message in _inbox whose flagged status is true)) | |
set _msglist to contents of _messages | |
-- Walk through all flagged messages in this box | |
repeat with _message in _msglist | |
set fromMsg to (extract name from sender of _message as string) | |
set subjMsg to (subject of _message as string) | |
set msgID to message id of _message | |
set msgBody to content of _message | |
tell application "Reminders" | |
make new reminder with properties {name:subjMsg, body:"From: " & fromMsg & newline & msgBody & "message://%3c" & msgID & "%3e"} | |
end tell | |
-- unflag the message | |
set flagged status of _message to false | |
end repeat | |
end repeat | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment