tell application "Mail"
set k to count of messages of mailbox laSource
if k > 0 then
repeat with myMessage in (every message of mailbox laSource)
set my_message to contents of myMessage
if year of (get date received of my_message) = 2005 then move
my_message to mailbox laDestination
end repeat
end if
end tell
To fix this situation, place the id of the messages which meet the
search criteria into a list.
When the loop is done, move the message ids in the list to the
desired location. Then we can talk about optimization