Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Moving single mail message to folder times out

Hello, I am using the script:

tell application "Mail"

set the_messages to selection

set this_message to item 1 of the_messages

set theSender to sender of this_message

move this_message to mailbox "Trash" of account "Main"

set selected messages of first message viewer to first message of first message viewer

end tell


and I get the "error "Mail got an error: AppleEvent timed out." number -1712"


Without the final "set selected messages" it sometimes works, and sometimes doesn't. When it does, there is no more selection, so I can't run it (or a similar one going to a different folder) without having to use the mouse to select a new message.


Further, I want the set selected messages at the end of the script so I can see which one is next, instead of guessing (my mail has been skipping the first 15 or so messages and giving me the 16th as 'first').


Basically, I just want 6 hot keys Fn+1-6 to move messages to one of 6 different folders.

Can anyone provide any help into what I'm doing wrong?

MacBook Pro, OS X Yosemite (10.10.4)

Posted on Jul 4, 2015 4:36 PM

Reply
Question marked as Best reply

Posted on Jul 5, 2015 1:25 AM

You might want to try something like this:


tell application "Mail"

activate

set C0 to countselection

set the_messages to selection

set this_message to item 1 of the_messages

set theSender to sender of this_message

movethis_messagetomailbox "Trash" of account "Main"

repeat until (countselection) < C0

end repeat

tell application "System Events"

keystroke "a" using {command down} -- Select All

key code 126 using {option down, command down} -- ↑ to select the first message

end tell

end tell

3 replies
Question marked as Best reply

Jul 5, 2015 1:25 AM in response to CrazyHobbit

You might want to try something like this:


tell application "Mail"

activate

set C0 to countselection

set the_messages to selection

set this_message to item 1 of the_messages

set theSender to sender of this_message

movethis_messagetomailbox "Trash" of account "Main"

repeat until (countselection) < C0

end repeat

tell application "System Events"

keystroke "a" using {command down} -- Select All

key code 126 using {option down, command down} -- ↑ to select the first message

end tell

end tell

Moving single mail message to folder times out

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