首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于查找邮件发件人的域并将其添加到规则的AppleScript

问用于查找邮件发件人的域并将其添加到规则的AppleScript
EN

Stack Overflow用户
提问于 2013-03-28 06:01:35
回答 2查看 703关注 0票数 2

这是为了处理垃圾邮件。现在我知道得更清楚了,每次我们打开一封垃圾邮件,垃圾邮件发送者都知道邮件id是有效的。将其标记为垃圾邮件或执行任何操作都没有帮助。

现在我的问题来了。我正在寻找我的Applescript的帮助。

下面是我想在运行脚本时遵循的逻辑

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

将域名添加到特定的邮件规则"Addedfilter“作为条件(这是可选的,如果我可以自动执行此部分的话就更好了)

我打算通过邮件服务使用它,以便将发件人ids的域名收集到我的邮件规则中。

代码语言:javascript
复制
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

注:标记“垃圾邮件”无济于事。此外,我也有一些动机来捕获垃圾邮件域ids。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-28 06:46:15

尝试执行以下操作以获取域:

代码语言:javascript
复制
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]}")

或者这样:

代码语言:javascript
复制
set theDomain to (do shell script "echo  " & quoted form of rich text 1 through -2 of theSender & " | awk -F \"@\" '{print $2}' $1")

然后,如果要将域条件添加到规则中,请执行以下操作:

代码语言:javascript
复制
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
EN

Stack Overflow用户

发布于 2021-04-15 16:30:40

获取域名的另一种方法:

代码语言:javascript
复制
    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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15670363

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档