Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pyth

macrumors member
Original poster
Mar 7, 2008
80
0
I'm trying to write a script that does a few things on wakeup every morning. So far, I've figured out how to open Safari with a particular URL, play a playlist in iTunes and get new mail. However, I'm having trouble with a little feature I thought would be nice. Here's what I've got so far:

say "Hey, wake up. I've got news for you." using "Ralph"
tell application "Safari"
open location "http://online.wsj.com/home-page"
end tell
tell application "Mail"
activate
check for new mail
mailbox "inbox"
exists unread count
If true then
say "You've got mail" using "Ralph
else
quit application
end tell

However, it's not working. I'd like to set it where after it checks for new mail, it says "You've got mail" using the voice "Ralph". I can't figure out for the life of me how to do that. I thought that I'd have to use a conditional, but it's not working. If you've got any ideas, I'd really appreciate them.

-Alex
 
Mail's a bitch to script.

This bit seems to work:

Code:
tell application "Mail"
	set x to unread count of inbox
	check for new mail
	delay 3
	set y to unread count of inbox
end tell

if x = y then
	say "You have no new messages, bub" using "Ralph"
else
	say "You've got mail" using "Ralph"
end if

You know you need to set Mail to check for mail only manually for this script to work (or at least work well)

I'll leave it to you to add the other bits.


mt
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.