2013-06-03 28 views
2

我是新手腳本,並且正在嘗試爲郵件寫一個簡單的腳本。我將用它在一個ical事件中發送我的草稿文件夾中的所有電子郵件。但是我遇到了一個錯誤,我不知道如何調試。這裏是我的腳本發送所有草稿在蘋果的郵件

tell application "Mail" 
set draftMessages to every message in drafts mailbox 
repeat with theMessage in draftMessages 
    set theSender to (sender of theMessage) 
    set theSubject to (subject of theMessage) 
    set theContent to (content of theMessage) 
    set theRecipients to (to recipients of theMessage) 
    set theAddress to (address of theRecipients) 

    set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, sender:theSender, address:theAddress, visible:true} 

    end repeat 
end tell 

這裏是與敏感信息的事件日誌替換爲等等。

tell application "Mail" 
get every message of drafts mailbox 
    --> {message id 23241 of mailbox "Drafts" of account "BLAH", message id 23236 of mailbox "Drafts" of account "BLAH"} 
get sender of message id 23241 of mailbox "Drafts" of account "BLAH" 
    --> "Blah Blah <[email protected]>" 
get subject of message id 23241 of mailbox "Drafts" of account "BLAH" 
    --> "test 2" 
get content of message id 23241 of mailbox "Drafts" of account "BLAH" 
    --> "test 2" 
get every to recipient of message id 23241 of mailbox "Drafts" of account "BLAH" 
    --> {to recipient 1 of message id 23241 of mailbox "Drafts" of account "BLAH"} 
Result: 
error "Can’t get address of {to recipient 1 of message id 23241 of mailbox \"Drafts\" of 
account \"BLAH\" of application \"Mail\"}." number -1728 from «class radd» of {«class 
trcp» 1 of «class mssg» id 23241 of «class mbxp» "Drafts" of «class mact» "BLAH"} 

回答

2

你確定你想一個新的消息?該郵件已存在於您的草稿文件夾中,並且沒有理由創建新郵件。這應該足以做你想做的事情:

tell application "Mail" 
set draftMessages to every message in drafts mailbox 
    repeat with theMessage in draftMessages 
     send theMessage 
    end repeat 
end tell 

如果這不是你想要的,那麼你需要重寫你的問題。

0

嘗試將新的消息告訴塊外...

tell application "Mail" 
    activate 
    set draftMessages to every message in drafts mailbox 
    repeat with theMessage in draftMessages 
     tell theMessage 
      set theSender to (sender of theMessage) 
      set theSubject to (subject of theMessage) 
      set theContent to (content of theMessage) 
     end tell 
     set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, sender:theSender, visible:true} 
    end repeat 
end tell 
+0

我認爲那樣會工作,但當我這樣做的時候它會一直運行。 :(謝謝,但 – SavgStorm

相關問題