Mail rule script stopping after one message?
I have a script for moving some SENT messages to a specific folder. It executes via a rule that triggers whenever any message is received. Sometimes, only one message is moved at a time and I do not know why. The script should move all relevant messages in the 'repeat' loop.
Script:
using terms fromapplication "Mail"
on perform mail action with messagestheSelectedMessagesfor ruletheRule
setmessageListto {}
setxtomessagesinmailbox "Sent Messages" inaccount "xxx"
set messageList to x
setxtomessagesinmailbox "Sent Messages" inaccount "yyy"
set messageList to messageList & x
setxtomessagesinmailbox "Sent Messages" inaccount "zzz"
set messageList to messageList & x
repeatwithifrom 1 tocountitemsinmessageList
set msg to item i of messageList
if all headers of msg contains "VC:" or all headers of msg contains "HOA:" then
set mailbox of msg to mailbox "VC-HOA" of mailbox "Local"
end if
endrepeat
end perform mail action with messages
endusing terms from
Thanks.
iMac, OS X El Capitan (10.11.3)