Skip to content

Instantly share code, notes, and snippets.

@dustmoo
Created April 22, 2020 23:12
Show Gist options
  • Save dustmoo/8e29654672a4a74a8423f3e20fe20e3a to your computer and use it in GitHub Desktop.
Save dustmoo/8e29654672a4a74a8423f3e20fe20e3a to your computer and use it in GitHub Desktop.
CleanJiraSpamFromOutlookExample 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
if msgSet is not {} then
repeat with aMessage in msgSet
set theAccount to account of aMessage
set theSubject to the subject of aMessage as text
set theBody to the plain text content of aMessage as text
set theID to the id of aMessage
set archiveFolder to folder "Folder Name" of theAccount
--Archive ServiceDesk Spam
set sdMatch to "SERVICE DESK"
set junkMatch to "This issue requires your attention"
set updateMatch to "Updates"
set nameMatch to "Your Name"
if (theSubject contains sdMatch) and (theBody contains junkMatch) then
set aMessage's is read to true
move aMessage to archiveFolder
end if
if (theSubject contains sdMatch) and (theBody does not contain nameMatch) then
set aMessage's is read to true
move aMessage to archiveFolder
end if
if (theSubject contains updateMatch) and (theBody does not contain nameMatch) then
set aMessage's is read to true
move aMessage to archiveFolder
end if
end repeat
end if
end tell
return true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment