Hi, I'm kinda new to AppleScript and I'm trying to write a script to count the number of email messages in a particular folder, that have been received today (for use in a Geek Tool window). I'm getting an error message (as follows) when I run the script:
The whole problem seems to be with the following line:
set messageDate to the date string of the (date received) of thisMsg
For some reason I can't figure, the "date string" and "date received" don't seem to want to play together. Any pointers or suggestions? Thanks in advance..
Here's the script so far...
Mail got an error: Cant make date string of date received of message id 30782 of mailbox "INBOX/Junk Mail" of account "MyEmailAccount" into type specifier.
The whole problem seems to be with the following line:
set messageDate to the date string of the (date received) of thisMsg
For some reason I can't figure, the "date string" and "date received" don't seem to want to play together. Any pointers or suggestions? Thanks in advance..
Here's the script so far...
tell application "System Events" to set MailIsRunning to (name of processes) contains "Mail"
if MailIsRunning then
tell application "Mail"
set junkCount to "0"
set thisDate to the date string of the (current date)
repeat with thisMsg in (get every message of mailbox "INBOX/Junk Mail" of account "MyEmailAccount")
set messageDate to the date string of the (date received) of thisMsg
if messageDate is equal to thisDate then junkCount = junkCount + 1
end repeat
end tell
return (junkCount as string)
end if
if MailIsRunning then
tell application "Mail"
set junkCount to "0"
set thisDate to the date string of the (current date)
repeat with thisMsg in (get every message of mailbox "INBOX/Junk Mail" of account "MyEmailAccount")
set messageDate to the date string of the (date received) of thisMsg
if messageDate is equal to thisDate then junkCount = junkCount + 1
end repeat
end tell
return (junkCount as string)
end if