如何使用applescript打开电子邮件? [英] How to open an email message using applescript?
问题描述
我正在编写一个小的applescript,该脚本可在查看器中检索所有未读"消息并循环它们.
I am writing a small applescript which retrieves all "unread" messages in the viewer and loops them.
我要完成两个目标:
-
我需要获取每封邮件的主题并执行正则表达式以查看其是否适合步骤2(例如:获取主题为{.*}的电子邮件)
I need to get the subject of each message and perform a regular expression to see if it's suitable for step 2 (ex: get emails with subject {.*})
我需要在单独的窗口上打开每条消息,四秒钟后,我需要关闭该窗口并继续下一条消息
I need to open each message on a separate window and after 4 seconds, I need to close that window and proceed with the next message
你知道怎么做吗?
谢谢.
推荐答案
以下applescript对我有用,但是我不确定如何进行正则表达式匹配.您可以将unix'grep'函数与applescript的'do shell script
'命令一起使用,但是我对如何正确使用grep并不熟练.我将其留给其他人回答.
The following applescript works for me, but I'm not sure how to do the regex matching. You can use the unix 'grep' function with applescript's 'do shell script
' command, but I'm no expert in how to use grep properly. I'll leave that for someone else to answer.
on run
tell application "Mail"
set myInbox to mailbox "INBOX" of account 1
set myMessages to every message of myInbox
repeat with theMessage in myMessages
if read status of theMessage is false then
if my subjectIsInteresting(subject of theMessage) then
open theMessage
delay 4
close window 1
end if
end if
end repeat
end tell
end run
on subjectIsInteresting(subject)
-- do some regex magic here
return true -- for now
end subjectIsInteresting
这篇关于如何使用applescript打开电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!