AppleScript: move message to folder

G

gconard

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: Intel
Email Client: Exchange

I'd like a simple AppleScript to move a message from the Inbox to another folder.

i've tried
move theMessage to folder "Filed"
and
move theMessage to folder "Filed" of folder "Inbox"

but i get a funky error in the script editor: "Can't get item 1 of {incoming message id 27469}".

I'm moving from Windows, have some macros for Outlook that keep me sane that I'm trying to replicate in Entourage...
 
B

Bras

Use the Entourage rules to move messages - go to Tools - Rules and setup a
rule to move messages to a special folder.
Once you have setup what you want you can apply the rule to all messages in
your inbox by selecting all and then control click the messages in the
folder list and choose to apply your rule, this will move all message with
your chosen criterions to your special folder.
Examles of rules:
http://www.entourage.mvps.org/rules/example/index.html
Using rules with Entourage:
http://www.entourage.mvps.org/rules/index.html
Get Started with rules:
http://www.entourage.mvps.org/rules/lesson.html

Bras
 
D

Diane Ross

I'd like a simple AppleScript to move a message from the Inbox to another
folder.

As Bras mentioned Rules can be used to move messages, but if you are wanting
to move a folder after reading to another folder, you can do this with a
script.

File Msgs in Folder By: Allen Watson
<http://tinyurl.com/6brn6c>

With one or more messages selected, this lets you type in a few characters
of a folder's name and moves the messages to that folder. If the match is
inconclusive, it presents a listing of the folders with the first match
selected and lets you select the one you want. Remembers last folder picked
for fast repeat operations. Shortcut assigned: Cmd-Shift-M, and typing the
folder name, will accomplish ALMOST the same thing, and about in the same
time.)

Open Folder By: Allen Watson
<http://tinyurl.com/69usgu>

Same concept of typing a folder's name, but opens a folder in your browser
window. For your five "main" folders such as Inbox, Outbox, Drafts, Sent,
and Deleted, you can create individual scripts with keyboard shortcuts for
rapid access, but this script lets you pick any folder. (Clicking on the
folder pane at left, and typing a name, will also select the folder, most of
the time.)

I have a few Move to folder xxx for specific folders I use frequently. This
script moves a folder named !To Add. Just modify the script for the folder
you want. Assign a shortcut for easy use. Drawback, too many folders can
start to get confusing and that¹s a lot of shortcuts to remember.

tell application "Microsoft Entourage"
try
set theMessages to current messages
on error
display dialog "select some messages before running this script."
buttons {"Quit Script"} default button 1 with icon stop
return
end try
try
move theMessages to folder "!To Add"
on error
display dialog "An error occurred and the messages were not moved.
Does the folder\"!Recent\" exist?" buttons {"Quit Script"} default button 1
with icon stop
return
end try
repeat with aMessage in theMessages
set the read status of aMessage to untouched

end repeat
end tell

Here is an example of a script that moves messages to a folder ³Read Mail²
that is a subfolder of the Inbox. I have a folder in my Entourage Scripts
folder named ³Move², inside are scripts that move to specific folders.

tell application "Microsoft Entourage"
try
set theMessages to current messages
on error
display dialog "select some messages before running this script."
buttons {"Quit Script"} default button 1 with icon stop
return
end try

try
move theMessages to folder "read mail" of folder "inbox"
on error
display dialog "An error occurred and the messages were not moved.
Does the folder\"read\" exist?" buttons {"Quit Script"} default button 1
with icon stop
return
end try
repeat with aMessage in theMessages
set the read status of aMessage to read

end repeat
end tell

If you have trouble copying this script from the forum, you might want to
subscribe to this newsgroup with Entourage so you can view it in HTML that
will not break the script. The Forum strips out HTML.
 
G

gconard

Thanks both Diane and Bras. AppleScript is definitely what's needed - the rules approach works but doesn't give the workflow I'm looking for (in outlook, have macros that I have assigned to Alt-W and Alt-Q that move msgs to predefined folders, so I crank through the inbox with the keyboard and get it to zero).

So I just tried some of the sample scripts and it turns out I had the right code in the first place, but just discovered an interesting quirk. If I run the script against a folder in a folder in "Folders on My Computer", it works (using Diane's move to !ToAdd script above).

However, if I run it against a message in the Inbox on our Exchange server, it doesn't work - and it fails silently, not even giving me the error dialogs.

Will start scouring the forums again to see if I can find the issue myself, but if you know offhand what the story is I'd love to know!

Thanks again!!

-george
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top