Hello Everyone
I am working on an elaborate script to replace my apple rules.
Trying to batch move emails based on a collection of either “id” or “message id”. Somehow I can’t get the syntax and/or classes right.
I have made this little test script to simplify the problem. Anybody have an idea ?
set fromAcc to "ACCOUNTNAME 1"
set fromMBox to "ATEST"
set toAcc to "ACCOUNTNAME 2"
set toMBox to "BTEST"
set listMoveIds to {}
set noOfMessagesInMailbox to 0
tell application "Mail"
-- Read All emails from mailbox
set usingMailbox to mailbox named fromMBox of account named fromAcc
-- Refference to aevery Msg
set refAllMessages to (a reference to every message in usingMailbox)
set noOfMessagesInMailbox to count of refAllMessages
-- catch id of every second Msg
repeat with N from 1 to noOfMessagesInMailbox by 2
set end of listMoveIds to id of item N in refAllMessages
end repeat --with N from 1 to noOfMessagesInMailbox by 2
end tell --Application "Mail"
display dialog ("No of mails in mailbox: " & noOfMessagesInMailbox & ", No of id's selected: " & (count of listMoveIds))
tell application "Mail" to move (every message of mailbox fromMBox of account fromAcc whose id is in listMoveIds) to mailbox toMBox of account toAcc
display dialog ("Finished")
Model: MacBook Pro
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14