Created
May 21, 2018 17:07
-
-
Save darrenpmeyer/9641de11f9bb183896a34d63b7e5ce9f to your computer and use it in GitHub Desktop.
AppleScript to make a new Notes.app Note in an Exchange account from the currently selected Outlook Calendar Events
This file contains 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
-- yes, that is an oddly specific use case; I suspect most people will just use this for | |
-- reference to solve their own problems ;) | |
tell application "Microsoft Outlook" | |
set currentEvents to selected objects | |
--log currentEvents | |
repeat with ev in currentEvents | |
try | |
set theSubject to the subject of ev | |
--log theSubject | |
set theStart to start time of ev | |
--log theStart | |
set {year:y, month:m, day:d} to theStart | |
set theStartTime to the time string of theStart | |
set strDate to "" & d & ". " & m & " " & y & " " & theStartTime | |
--log strDate | |
set theNoteName to "[M] " & theSubject & " @ " & theStartTime | |
tell application "Notes" | |
activate | |
tell account "Exchange" | |
-- try finding a note with this name | |
set matchingNotes to my findNoteByTitle("Exchange", theNoteName) | |
if matchingNotes is {} then | |
-- activate the existing note! | |
make new note at folder "Notes" with properties {name:theNoteName} | |
set newNote to first item of my findNoteByTitle("Exchange", theNoteName) | |
else | |
-- create a new note | |
set newNote to first item of matchingNotes | |
log newNote | |
end if | |
end tell | |
show newNote | |
end tell | |
on error errMsg | |
display alert errMsg | |
log errMsg | |
end try | |
end repeat | |
end tell | |
on findNoteByTitle(accountName, theNoteName) | |
tell application "Notes" | |
tell account accountName | |
-- try finding a note with this name | |
set matchingNotes to (every note whose name is equal to theNoteName) | |
log matchingNotes | |
return matchingNotes | |
end tell | |
end tell | |
end findNoteByTitle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment