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)

Posted on Sep 19, 2016 2:41 PM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Mail rule script stopping after one message?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.