Applescript and Rules

G

G. Miller

Hello,

I am running os10.3.8 and entourage x.

I have a few email accounts that are checked for new messages on a schedule
(every 5 minutes).

I created a rule that uses an applescript to speak the name of the account
that any new mail arrives in. for example, if there is a new message (using
pop server, not imap) on the server after the check mail script is run for
account A, the rule is applied, the applescript is run, and the comnputer
says "account A".
The problem I am running into is in the situation when there is more than
one new message for an account, the computer says "account A" "account
A".... In the morning when I first check the email, there may be 20 messages
and it just repeats and repeats. I only want the computer to say the
account name once if there is new mail.

If there a way that I can apply a rule to only the first message of each
account? Perhaps I could create an applescript that checks the mail and
tells me the number of new messages on each account?

Any advice is appreciated.

G.Miller
 
P

Paul Berkowitz

I am running os10.3.8 and entourage x.

I have a few email accounts that are checked for new messages on a schedule
(every 5 minutes).

I created a rule that uses an applescript to speak the name of the account
that any new mail arrives in. for example, if there is a new message (using
pop server, not imap) on the server after the check mail script is run for
account A, the rule is applied, the applescript is run, and the comnputer
says "account A".
The problem I am running into is in the situation when there is more than
one new message for an account, the computer says "account A" "account
A".... In the morning when I first check the email, there may be 20 messages
and it just repeats and repeats. I only want the computer to say the
account name once if there is new mail.

If there a way that I can apply a rule to only the first message of each
account? Perhaps I could create an applescript that checks the mail and
tells me the number of new messages on each account?

The thing is that rules are run and re-run on each new message as it comes
in. That's how rules work. Normally that's exactly what you'd want, but not
here, I don't see a fool-proof method. If you have 20 messages coming in
then including a

repeat while connection in progress
end repeat

would delay the continuation of the scrip, and the announcement, until all
messages had downloaded. You could then check for

set n to (count every message of inbox folder whose read status is
false)
if n > 0 then
say (n as string) & " new messages downloaded"
set read status of every message of in box folder to read
set selection to (current messages)
end if

although it would also include any unread messages you never got around to
previously. Bu setting all messages to Read, the script would do nothing on
the subsequent message. But you'd have to look hard on the "Online Status"
icon to see which messages were actually not yet read (jagged envelope). The
last line (current messages) will select the _first_ new message only - so
all later messages will actually be unread and you can carry on from there.
This might work OK.

An alternate method would be to run the script not from a rule but as the
final action of the Send & Receive All schedule. You should still include :

repeat while connection in progress
end repeat
set n to (count every message of inbox folder whose read status is
false)
if n > 0 then
say (n as string) & " new messages downloaded"
else
--say "No new messages".
end if


I think this would work better.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
G

G. Miller

repeat while connection in progress
end repeat

would delay the continuation of the scrip, and the announcement, until all
messages had downloaded. You could then check for

set n to (count every message of inbox folder whose read status is
false)
if n > 0 then
say (n as string) & " new messages downloaded"
set read status of every message of in box folder to read
set selection to (current messages)
end if

Thanks, I will try this.

Geoff
 
Top