对于给定的消息,我想在其线程中获取所有消息,例如:
tell application "Mail"
if content of theMessage contains "merged #" then
# repeat with otherMessage in the thread of theMessage
set background color of otherMessage to green
# end repeat
end if
end tell
我该怎么做/它有可能吗?
(我知道我可以遍历theMessage
邮箱中的所有邮件并比较主题,但效率不高)
答案 0 :(得分:0)
set myTitle to "subject of my thread" --only the subject without 're:' or 'Fwd:'
tell application "Mail"
set myEmails to {}
set MailSent to {every message of sent mailbox whose subject contains myTitle}
set Mailreceived to {every message of inbox whose subject contains myTitle}
set BoxList to name of every mailbox
repeat with aBox in BoxList
set end of myEmails to {every message of mailbox aBox whose subject contains myTitle}
end repeat
end tell
display dialog "sent=" & (count of MailSent) & return & "receipt=" & (count of Mailreceived) & return & "other=" & (count of myEmails)
答案 1 :(得分:0)
好吧,如果您收到主题为re: subj
的邮件,则无法使用fwd: subj
运营商找到主题为contains
的邮件。
所以这是一个剥离re
和fwd
的函数:
-- Email subject canonization
-- Strips 're:', 'fwd:', etc. from the beginning of the text string passed in.
on canonizeSubject(theSubject)
return do shell script "export LC_ALL=en_US.UTF-8; export LANG=en_US.UTF-8; shopt -u xpg_echo; echo " & quoted form of theSubject & " | perl -C -Mutf8 -pe 's/^(re|fwd|\\s|:)*//i'"
end canonizeSubject
用法是:
set theSubject to my canonizeSubject(subject of theMessage)
set messagesInTheThread to messages of mailbox of theMessage whose subject contains theSubject
但实际上,这并不是一种完整的电子邮件分组方式。为了正确,您应该分组到线程中,而不是通过匹配主题,而是使用References
标题搜索原始邮件。
请在此处查看详细信息:https://cr.yp.to/immhf/thread.html