forked from raycast/script-commands
/
screen-out.applescript
executable file
·38 lines (31 loc) · 1.05 KB
/
screen-out.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Screen Out
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 🤖
# Documentation:
# @raycast.description Screen this message out of my inbox
# @raycast.author Bryan Schuetz
# @raycast.authorURL https://github.com/BryanSchuetz
tell application "Mail"
-- Start by getting the sender's address and the message's account
set selectedMsgs to selected messages of first message viewer
set thisMsg to first item of selectedMsgs
set acct to account of mailbox of thisMsg
set spamAddr to extract address from sender of thisMsg
get acct
-- Add that address to a new condition of the rule
set psRule to rule "Screened Out"
tell psRule
set newCondition to make new rule condition at beginning of rule conditions
tell newCondition
set rule type to from header
set qualifier to equal to value
set expression to spamAddr
end tell
end tell
-- Delete the message
set mailbox of thisMsg to mailbox "Screened Out" of acct
end tell