Skip to content

Instantly share code, notes, and snippets.

@dustmoo
Last active April 22, 2020 23:20
Show Gist options
  • Save dustmoo/b2cacd9c0ded7bf510c7955d65fa431f to your computer and use it in GitHub Desktop.
Save dustmoo/b2cacd9c0ded7bf510c7955d65fa431f to your computer and use it in GitHub Desktop.
Send Selected Outlook Messages to Things Applescript
tell application "Microsoft Outlook"
activate
set msgSet to current messages
if msgSet = {} then
error "No Messages selected. Select at least one message."
error -128
end if
set theMessage to item 1 of msgSet
set theAccount to account of theMessage
set theSubject to the subject of theMessage
set theBody to the plain text content of theMessage
set theID to the id of theMessage
set archiveFolder to folder "Folder Name" of theAccount
if msgSet is not {} then
repeat with aMessage in msgSet
set aMessage's is read to true
move aMessage to archiveFolder
end repeat
end if
end tell
set bodyLength to the length of theBody
if (bodyLength < 400) then
set trimLength to bodyLength as number
else
set trimLength to 400
end if
set truncatedBody to trim_line(theBody, trimLength)
tell application "Things3"
show quick entry panel with properties {name:theSubject, notes:truncatedBody}
end tell
on trim_line(this_text, trim_chars)
-- 0 = beginning, 1 = end, 2 = both
set i to 1
set e to trim_chars
set this_text to characters i thru e of this_text as string
return this_text
end trim_line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment