Handlers within scripts have a default timeout of 60 seconds. Try this.
tell application "Mail"
set fetches automatically to false
set selectedMessages to (messages of mailbox "Spam Virus Mail" of mailbox "Personal" whose date received is less than today - (2 * days))
set messcount to (count of selectedMessages)
if (count of selectedMessages) is equal to 0 then
tell application "Finder"
activate
display alert "No mail in the Spam Virus Mail mailbox is older than 2 days" message "Try running this script later on. Rob." giving up after 2
end tell
else
try
with timeout of 600 seconds
repeat with i from messcount to 1 by -1
set theSource to item i of selectedMessages
set background color of theSource to red
delete theSource
end repeat
end timeout
end try
end if
end tell
tell application "Mail"
set fetches automatically to false
set selectedMessages to (messages of mailbox "Spam Virus Mail" of mailbox "Personal" whose date received is less than today - (2 * days))
set messcount to (count of selectedMessages)
if (count of selectedMessages) is equal to 0 then
tell application "Finder"
activate
display alert "No mail in the Spam Virus Mail mailbox is older than 2 days" message "Try running this script later on. Rob." giving up after 2
end tell
else
try
repeat with i from messcount to 1 by -1
set theSource to item i of selectedMessages
set background color of theSource to red
delete theSource
end repeat
end try
end if
end tell