繁体   English   中英

使用Applescript搜索Mail.app的邮箱

[英]Search Mailbox of Mail.app with Applescript

我希望能够在Apple的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

您还可以在界面中调用真实搜索,然后收集项目

    [Applications launch:@"Mail"];
    [Keyboard command_alt_press:'f'];
    [Keyboard paste:term];


+(void) command_alt_press:(char)c{
    [self runScript:[NSString stringWithFormat:@"tell application \"System Events\" to keystroke \"%c\" using command option down",c]];
}

您似乎有能力完成其余的代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM