2016-12-05 2 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メールの手順はスレッドをサポートしていません。回避策は、タイトルにxxxxが含まれているすべてのメッセージを選択し、そのリストをループすることです。 – pbell

+0

@pbell、ありがとう。私は 'theMessage'の主題と等しい主題を持つメールボックスのメッセージに' theThreadMessagesを設定する 'のように思えます。あなたは主語を正当化する方法があるのでしょうか?(例:すべての「fwd:」と「re:」など) – Zelta

+0

の代わりに "被験者が等しい"を使用する必要があります。 ASはあなたが探している主題の一部であるすべてのメッセージをあなたに提供します。 – pbell

答えて

0

さてあなたは、件名re: subjとのメッセージを受信した場合、あなたはcontains演算子を用いて被験者fwd: subjとのメッセージを見つけることができません。だからここ

refwdを除去する機能です。

set theSubject to my canonizeSubject(subject of theMessage) 
set messagesInTheThread to messages of mailbox of theMessage whose subject contains theSubject 

しかし、実際に、それは電子メールをグループ化する完全な公正な方法ではありません。

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

使用量があります。正確にするには、件名を一致させるのではなく、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) 
関連する問題