这是为了处理垃圾邮件。现在我知道的更好,每次打开垃圾邮件时,垃圾邮件发送者都知道电子邮件ID是有效的。将其标记为垃圾邮件或做任何事情都无济于事。
现在我的问题。我正在寻找Applescript的帮助。
查找发件人电子邮件ID 解析获取域名(我被困在这里)
我打算通过邮件服务使用它,以便将发件人ID的域名收集到我的邮件规则中。
tell application "Mail"
set theSelection to selection
set theMessage to item 1 of theSelection
set theSender to sender of theMessage
--set theDomain to (do shell script "cut -f1 -d'@' $1" & quoted form of theSender)
set theDomain to (do shell script "awk -F\"@\" '{print $2}'" & quoted form of theSender)
display dialog theDomain
end tell
PS:标记“垃圾邮件”没有帮助。此外,我有一些动机来捕获垃圾邮件域ID。
答案 0 :(得分:0)
尝试此操作以获取域名:
set theDomain to (do shell script "echo " & quoted form of rich text 1 through -2 of theSender & " | awk " & quoted form of "{split($0,a,\"@\"); print a[2]}")
或者这个:
set theDomain to (do shell script "echo " & quoted form of rich text 1 through -2 of theSender & " | awk -F \"@\" '{print $2}' $1")
然后,如果要将域条件添加到规则中,请执行以下操作:
set r to rule "Addedfilter"
tell r
make new rule condition at end of rule conditions with properties {expression:theDomain, qualifier:does contain value, rule type:from header}
end tell
答案 1 :(得分:0)
另一种获取域的方法:
set theSelection to selection
set theMessage to item 1 of theSelection
set theEmail to extract address from sender of item 1 of theMessage
set AppleScript's text item delimiters to "@"
set theDomain to text item 2 of theEmail
在这里找到: https://forum.keyboardmaestro.com/t/extract-domain-name-from-current-email-and-open-in-safari/2904/5