Вопрос Applescript: повторите действие в ПОЧТЕ для выбранных сообщений

Вопрос. Я хочу запустить сценарий Apple для списка выбранных сообщений в Apple OS X Mail.

Прямо сейчас сценарий, который я написал, будет работать только с одним выбором, поэтому я предполагаю, что проблема заключается в том, как зациклить его для всех выбранных элементов. Любая помощь будет оценена по достоинству.

Вот сценарий:

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

person Billie Hawkins    schedule 01.04.2011    source источник


Ответы (1)


set theSelectedMessage to item 1 of theSelection

Замените это на:

repeat with theSelectedMessage in theSelection

Перед последней строкой добавьте:

end repeat
person kindall    schedule 01.04.2011
comment
Киндалл, Большое спасибо. Я часами играл с повторяющимися циклами, чтобы заставить это работать. Rockstar! - person Billie Hawkins; 02.04.2011