2011-04-01 23 views
0

問題:我想針對Apple OS X Mail中的選定郵件列表運行applescript。Applescript問題:在選定郵件的郵件中重複一個操作

現在,我寫的腳本只能用於單個選擇,所以我猜測問題是如何循環選擇所有項目。任何幫助,將不勝感激。

下面是腳本:

tell application "Mail" 

set theSelection to selection 
set theSelectedMessage to item 1 of theSelection 
set theSelectedMessageSender to sender of theSelectedMessage 
set theSelectedMessageRecipient to address of to recipients of theSelectedMessage 
set theSelectedMessageSenderName to extract name from sender of theSelectedMessage 
set theSelectedMessageSenderAddress to extract address from sender of theSelectedMessage 
set theSelectedMessageSubject to subject of theSelectedMessage 
set theSelectedMessageContent to content of theSelectedMessage 


set MessageText to ¬ 
"This email (" & theSelectedMessageRecipient & ") does NOT ¬ 
care to receive emails regarding this matter." & return & return & ¬ 
"This email was originally delivered to: " & ¬ 
theSelectedMessageRecipient & return & return & ¬ 
"Remove this email from your list: " & ¬ 
theSelectedMessageRecipient & ¬ 
return & return & ¬ 
"---------- ORIGINAL MESSAGE ----------------" 

set theMessage to make new outgoing message with properties {visible:true, subject:"REMOVE: RE:" & theSelectedMessageSubject, content:MessageText & theSelectedMessageContent, reply to:theSelectedMessageRecipient} 
tell theMessage 
    make new to recipient at end of to recipients with properties {name:theSelectedMessageSenderName, address:theSelectedMessageSenderAddress} 
end tell 
end tell 

回答

1
set theSelectedMessage to item 1 of theSelection 

替換爲這樣:

repeat with theSelectedMessage in theSelection 

剛剛過去的前行,添加:

end repeat 
+0

Kindall,謝謝非常。我一直在玩幾個小時的重複循環,以使其工作。搖滾明星! – 2011-04-01 21:37:51

+2

非常歡迎。不要忘記選擇它作爲答案。 :-) – kindall 2011-04-01 21:39:57