使用 Applescript 搜索 Mail.app 的邮箱

标签 search macos email applescript

我希望能够在苹果的 mail.app 中的邮箱中搜索某个短语或单词,然后以某种方式返回或复制从搜索结果中成功返回的电子邮件所发送的所有电子邮件地址来自..如果你明白我的意思

我认为做到这一点的唯一方法可能是 applescript,但如果其他人知道任何其他方法,请告诉我:)

最佳答案

Mail.app 不允许直接通过 Applescript 进行搜索,但这可以解决问题,尽管它有点慢,因为它必须遍历每条消息:

global searchTerm
property emailList : {}

set searchTerm to "aSearchTerm"

tell application "Mail"

    set theInbox to inbox

    set firstMessage to 1
    set lastMessage to (get count of messages in theInbox)

    repeat with thisMessage from firstMessage to lastMessage
        set currentMessage to message thisMessage of theInbox

        set messageContent to content of currentMessage

        if messageContent contains searchTerm then
            set end of emailList to sender of currentMessage
        end if

    end repeat

end tell

return emailList

关于使用 Applescript 搜索 Mail.app 的邮箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1916755/

相关文章:

wordpress - 在 woocommerce 搜索中包含自定义字段值

macos - 如何在我的 MacOS 系统上构建 RPM?

java - 使用 jxl 发送电子邮件

email - 使用AutoIt发送电子邮件

java - 从文本文件中查找最大值

python - 使用 BeautifulSoup 抓取 Google 搜索

c++ - 在 mac 上的 gnu/clang 编译器中定义相对于可执行文件的框架路径

macos - 如何在 Mac OSX 10.6 上安装 Perl DateTime 模块

algorithm - 如何搜索影响空间点的对象