【发布时间】:2013-01-26 22:18:43
【问题描述】:
我希望能够在苹果的 mail.app 中的邮箱中搜索一个阶段或单词,然后以某种方式返回或复制从搜索结果中成功返回的电子邮件已发送的所有电子邮件地址来自..如果你明白我的意思
我认为这样做的唯一方法可能是 applescript,但如果其他人知道任何其他方法,请告诉我 :)
【问题讨论】:
标签: search macos email applescript
我希望能够在苹果的 mail.app 中的邮箱中搜索一个阶段或单词,然后以某种方式返回或复制从搜索结果中成功返回的电子邮件已发送的所有电子邮件地址来自..如果你明白我的意思
我认为这样做的唯一方法可能是 applescript,但如果其他人知道任何其他方法,请告诉我 :)
【问题讨论】:
标签: search macos email 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
【讨论】:
theInbox,所以我发布了最终对我有用的版本:set theInbox to mailbox "INBOX" of account "myaccount"
您也可以在界面中调用真正的搜索,然后收集物品
[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]];
}
您似乎有能力完成其余代码。
【讨论】: