selecting a message in Mail
selecting a message in Mail
- Subject: selecting a message in Mail
- From: Jim Brandt <email@hidden>
- Date: Fri, 18 Sep 2009 09:07:23 -0500
Is there a way to select a specific message in a mailbox
in the Mail application?
My problem:
I currently have a script that works on a selected
message (it saves the message as text and moves
it to another mailbox after marking it as read, using
GUI scripting, which requires me to select the message
by hand, one at a time).
Instead of opening the viewer window and selecting
the messages, I want Applescript to do it for me.
So far, I have this:
tell application "Mail"
set mail_accounts to name of every account
set main_acct to item 1 of mail_accounts as text
tell account main_acct
set mcount to count of messages in mailbox "Inbox"
set new_mess to unread count of mailbox "Inbox"
if new_mess > 0 then
set cnt to 0
set all_checked to false
repeat with m from 1 to mcount
set ThisMess to message m in mailbox "Inbox"
set read_status to read status of ThisMess
set subj to subject of ThisMess
if not read_status then
set cnt to cnt + 1
display dialog subj giving up after 3
if cnt ≥ new_mess then exit repeat
end if
end repeat
end if -- new_mess > 0
end tell -- main_acct
end tell -- Mail
Currently, all this does is display the subject of all unread messages.
When I put:
select message m in mailbox "Inbox"
in place of the display dialog, I get this error:
Mail got an error: message 2 of mailbox "Inbox" of account
"Comcast Account" doesn't understand the select message.
In order to incorporate the piece of my currently working script,
I need to select one of these messages. Using the content of
"subj" I can isolate the message I want but can't figure out how
to select this message so I can process it. The SDEF for Mail
doesn't show a select command. Any suggestions?
Is there a website that contains example Applescript that works
with the Mail application?
TIA
Jim Brandt
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden