2013-04-11 60 views
2

我想要做的是設置一個Mail.app規則,將所有iTunes收據電子郵件重定向到Evernote中的特定筆記本。以下AppleScript添加正確的收件人並修改主題行,以便可以將指針包含到正確的Evernote筆記本中。問題是我無法弄清楚爲什麼電子郵件的內容被複制兩次。任何幫助表示讚賞。使用AppleScript重定向電子郵件時,電子郵件的內容是重複的。爲什麼?

更新:爲了說明起見,此腳本作爲Mail.app規則的一部分運行。當一封電子郵件與規則匹配時,下面的AppleScript將運行。如果您不熟悉Evernote通過電子郵件添加項目的能力,它的工作原理如下:每個印象筆記用戶都會收到一個唯一的電子郵件地址,以便將項目直接添加到印象筆記帳戶。在主題行中,可以添加某些關鍵字以將文檔導向特定文件夾(@Receipts)或添加特定標籤(#cool)。

using terms from application "Mail" 
on perform mail action with messages theMessages 
    repeat with thisMessage in theMessages 
     tell application "Mail" 
      set newMessage to redirect thisMessage with opening window 
      tell newMessage 
       set subject of newMessage to "hello" 
       make new to recipient at beginning of to recipients with properties {address:"[email protected]"} 
       delete bcc recipients 
       delete cc recipients 
      end tell 
      set the sender of newMessage to "[email protected]" 
      delay 1 
      -- send newMessage 
     end tell 
    end repeat 
end perform mail action with messages 
end using terms from 
+0

這可能有助於診斷:它發生在'重新創建收件人...'之後。 – 2013-04-11 03:05:27

+0

是的,我也注意到了,但我無法弄清楚爲什麼會發生這種情況,或者我的替代方案是爲了實現相同的目標。 – 2013-04-11 03:54:37

回答

0

我試過這個與Mac OS X 10.6.8和郵件4.6.1085和純文本電子郵件。電子郵件的正文在開始時並沒有在這個設置中重複,但是我注意到它在另一個自動回覆函數中被複制。事情是這樣的:

  1. 寫文本與主題的電子郵件 「Evernote的」 2)下載電子郵件, 主題 「Evernote的」 觸發從我的支持E-mail, 看起來正常的自動回覆
  2. 支持自動回覆(這被送到 自己,因爲它是一個測試)觸發Evernote的腳本(下)
  3. Evernote的腳本引用原郵件並插入同一消息的副本 。

我認爲你可以通過存儲原始文本並在發送消息之前再次設置它來解決這個問題。以下似乎沒有重複的文本發送消息:

using terms from application "Mail" 
    on perform mail action with messages theMessages 
     repeat with thisMessage in theMessages 
      tell application "Mail" 
       set theText to content of thisMessage 
       set newMessage to redirect thisMessage with opening window 
       tell newMessage 
        set subject of newMessage to "hello" 
        make new to recipient at beginning of to recipients with properties {address:"[email protected]"} 
        delete bcc recipients 
        delete cc recipients 
       end tell 
       set the sender of newMessage to "[email protected]" 
       set content of newMessage to thisText 
       delay 1 
       -- send newMessage 
      end tell 
     end repeat 
    end perform mail action with messages 
end using terms from 
0

我有同樣的問題,當我試圖轉發消息(運行10.6至10.9) 我通過存儲的內容固定它在添加另一個主題等之前的新消息...

set themessage to forward eachMail with opening window 
set a to content of themessage 
set thesubject to (subject of eachMail) as rich text 
    tell themessage 
     set subject to thesubject 
     repeat with m in mailtos 
      make new to recipient at end of to recipients with properties {address:m} 
     end repeat 
     set content to a 
    end tell