Mac Automator/Applescript(?) 从邮件消息中提取 URL [英] Mac Automator/Applescript(?) to extract URL's from Mail messages

查看:26
本文介绍了Mac Automator/Applescript(?) 从邮件消息中提取 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取驻留在最新 Mac Mail.app (OS X 10.10.2 Yosemite) 中的一堆电子邮件中任何链接的文本文档列表,但我很困惑.

I'm trying to get a text document list of any links in a bunch of email messages that reside in the latest Mac Mail.app (OS X 10.10.2 Yosemite), and am simply stumped.

我以为我可以……

  1. 将几个 Automator.app 操作放在一个服务/工作流中,
  2. 选择/突出显示 Mail.app 中的所有电子邮件,
  3. 选择该服务或运行该工作流,
  4. 并且有一个文本文档,其中包含所有可以在其中找到的每个 URL/链接.

然而,这没有用.

我想出了如何通过一次一个电子邮件来实现这一点,但这不是我想要的.附件是 3 个工作流程的屏幕截图.第一个是只处理一封电子邮件的邮件 &突出显示其中的所有文本 &运行服务.其他两个根本不起作用.

I figured out how to do this with one email message at a time, but that's not what I want. attached is a screenshot of 3 workflows. The first one is the one that works with just one email message & highlighting all the text in it & running the Service. the other two just simply don't work.

我还注意到第一个出现在服务菜单中,并打开了一封电子邮件;一旦我突出显示不止一封电子邮件,该选项就会从服务"菜单中消失.

I also notice that the the first shows up in the Service Menu with a single email open; once I highlight more than one email message, the option goes away from the Service menu.

有什么提示或技巧吗?

推荐答案

我想出了如何实现目标,从在 Automator 中创建新服务开始(输入:无输入",应用程序:邮件")

I figured out how you could reach your goal, start with creating a new service within Automator (input: "No input", application: "Mail")

第一个操作是Get Selected Mail Messages(获取选定邮件)

The first action is Get Selected Mail Messages (Get selected: messages)

第二个操作是使用以下脚本执行 AppleScript:

The second action is Execute AppleScript with the following script:

on run {input, parameters}
    set mailContentList to {}
    tell application "Mail"
        repeat with selectedMail in input
            set end of mailContentList to content of selectedMail
        end repeat
    end tell
    return mailContentList
end run

这个脚本只是遍历给定的消息,读出内容并将这个列表传递给下一个动作

第三个操作是从文本中提取网址.这被列为从文本中提取数据",其中一种数据类型是URL".

The third action is Extract URLs from Text. This is listed as "Extract Data from Text" and one of the types of data is "URLs".

最后的动作是新建文本编辑文档

用一个好听的名字保存它,比如从选定的邮件中提取 URL之后,该服务将在邮件应用内的服务"菜单中可用.

Save it with a nice name like Extract URLs from selected mails After that the Service is available inside the Services menu inside the Mail app.

在我的测试中,我发现了一些没有 http://的内部 URL,从链接到锚点,所以也许您想删除所有不以 http 开头的 URL.您可以通过在创建新的 TextEdit 文档之前使用另一个操作来实现:
过滤段落带有选项以http开头的段落"(不知道这些参数在英文Automator中是如何调用的,抱歉)

In my test I found a few internal URLs without http:// from links to anchors, so maybe you want to delete all URLs that do not start with http. You can do so by using another action before creating the new TextEdit document:
Filter Paragraphs with options "Paragraphs that start with http" (don't know how these parameters are called in English Automator, sorry)

感觉很好,迈克尔/汉堡

Feel good, Michael / Hamburg

这篇关于Mac Automator/Applescript(?) 从邮件消息中提取 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆