Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AppleScript: move message to folder

1,860 views
Skip to first unread message

gco...@officeformac.com

unread,
Mar 11, 2009, 10:33:13 PM3/11/09
to
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...

Bras

unread,
Mar 12, 2009, 8:32:36 AM3/12/09
to
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

<gco...@officeformac.com> wrote in message
news:59b6f...@webcrossing.caR9absDaxw...

Diane Ross

unread,
Mar 12, 2009, 6:01:52 PM3/12/09
to
On 3/11/09 7:33 PM,  "gco...@officeformac.com" <gco...@officeformac.com> wrote:

> 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.


--
Diane

gco...@officeformac.com

unread,
Mar 23, 2009, 2:30:39 PM3/23/09
to
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

Diane Ross

unread,
Mar 23, 2009, 3:59:15 PM3/23/09
to
On 3/23/09 11:30 AM, "gco...@officeformac.com" <gco...@officeformac.com>
wrote:

> 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.

Mind you I'm not a scripting expert...maybe copy rather than move. Check out
the script that autoarchives Exchange messages to folders "On My Computer"
as an example:

<http://www.entourage.mvps.org/downloads/scripts/AutoArchive.zip>

--
Diane

atmiya...@gmail.com

unread,
Jul 9, 2014, 3:13:15 AM7/9/14
to
hello sir,
if possible to export all outlook mail as a .mbox format using apple script .
please reply

thanks

Kwasi Glover

unread,
Sep 7, 2023, 4:36:24 PM9/7/23
to
Hi Diane,
I'd like to write an Apple script that could allow me to read all emails that arrive in the mail under Inbox as they currently do. 5mins after reading/closing or opening another mail, the script is activated and moves mails under the rules I have already set ... I mean into different specific folders automatically (more than 7 sorted folders). I would like to set a Mail rule to do this, but can't find a way. The only way, I guess, is through an Apple script.
Any tips would be appreciated.

Please note: I don't know how to go about Apple script, but I am ready to learn.
0 new messages