attempting to count messages in Mail
attempting to count messages in Mail
- Subject: attempting to count messages in Mail
- From: David Rogers <email@hidden>
- Date: Tue, 6 Nov 2001 13:45:30 -0600
I am new to apple script (started this morning) but I was trying to add
some functionality that I have gotten used to in my other mail programs,
to the Mail.app in osX
I would like to count the number of messages (read or unread it doesn't
matter) in the inbox of any account and if the count is over 200 i'd
like to delete the messages from oldest to newest until there are only
200 messages in the folder.
here is what I have so far:
property mailcount : ""
tell application "Mail"
activate
repeat with this_account in (every account as list)
display dialog "current account is " & account name of this_account
set mailcount to (count every message of the mailbox "inbox")
display dialog "current messages in box =" & mailcount
if the mailcount > 200 then
display dialog "you have more than 200 messages in your
inbox would you like to delete the excess?" buttons {"Cancel", "OK"}
default button 1
copy the result as list to {button_pressed}
if the button_pressed is "OK" then
repeat
if mailcount b $ 200 then
exit repeat
else if mailcount > 200 then
(* not sure is this is right as the script never gets here
delete message 1 of the "inbox"
mailcount = mailcount - 1 *)
end if
end repeat
display dialog " messages deleted"
end if
end if
end repeat
end tell
at this stage every time the script sets mailcount it is set to 0
any help or suggestions would be appreciated
Thanks,
-David Rogers