2016-12-05 58 views
0

对于给定的消息,我想在其线程的所有消息的所有消息,例如:查找线程

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

Applescript Mail指令不支持线程。解决方法是选择标题包含xxxx的所有消息,然后遍历该列表。 – pbell

+0

@pbell,谢谢。好像我应该使用'将theThreadMessages设置为邮件主题等于邮件主题的邮件箱'。你知道吗,是否有一种方法可以封锁主题(例如去掉所有'fwd:'和're:'等)? – Zelta

+0

而不是“谁的主题等于”,你应该使用“谁的主题包含”。 AS会给你所有关于哪个部分的主题是你正在寻找的信息。 – pbell

回答

0

好吧,如果你收到主题re: subj一个消息,你将无法找到消息使用contains运营主体fwd: subj

所以这里是剥离refwd功能:

-- 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

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)