2

这是为了处理垃圾邮件。现在我知道了,每次我们打开垃圾邮件时,垃圾邮件发送者都知道电子邮件 ID 是有效的。将其标记为垃圾邮件或做任何事情都无济于事。

现在我的问题。我正在为我的 Applescript 寻求帮助。

这是我运行脚本时要遵循的逻辑

查找发件人电子邮件 id 解析以获取域名(我被困在这里)

将域名添加到特定的邮件规则“Addedfilter”作为条件(如果我可以自动化这部分,这是可选的)

我打算通过邮件服务使用它,以便将发件人 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。

4

2 回答 2

1

试试这个来获取域:

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
于 2013-03-27T22:46:14.843 回答
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

于 2021-04-15T08:30:39.960 回答