Applescript for Reading Email to me
I want a script that will take my gmail account, find new emails, and read them to me using the "say" function and not display anything on the screen. Is that possible?
Mac OS X (10.7.1)
I want a script that will take my gmail account, find new emails, and read them to me using the "say" function and not display anything on the screen. Is that possible?
Mac OS X (10.7.1)
Possible? it's trivial, but if your inbox is anything like mine it's going to get annoying, really quickly 🙂
tell application "Mail"
set unreadMessages to (get every message of mailbox "INBOX" of account "Gmail" whose read status is false)
repeat with eachMessage in unreadMessages
say (get content of eachMessage)
end repeat
end tell
Is there a way to mark it as read after it has read it to me? Also (and I know I'm getting technical but this is for a friend who can't see) is there a way to make it say something in between the messages so that he will know the difference between messages? Like have it say "Message 1: <says message>" "Message 2: <says message>" and so forth? Thanks so much for the help this was great!!!!!
Or maybe instead have it say "Subject: <says subject> Message: <says Message>" for each message...idk what do you think?
Nevermind! I got it to do everything but mark the message as read in the inbox. Is that possbile? Plus with his gmail he has different folders set up so not all the new messages go to the inbox is there a way to get it to read him those messages that are in his subfolders as well. They skip them inbox and go straight to labels or folders in the Mail app. Thanks again!
Yes, it's all possible.
mark the message as read in the inbox
just put:
set read status of eachMessage to true
inside the repeat loop, after the say statement.
is there a way to get it to read him those messages that are in his subfolders as well
Sure, you asked for the inbox, so that's what I showed you. Just substitute any other mailbox name... e.g. 'every message of mailbox "blah" of account "Gmail"...' You could even use 'every message of every mailbox...' if you want.
I have a folder called Work but when I replaced INBOX with Work it gave me an error :-/
if it doesn't have any new message what do i need to put in to make it say "no new messages" if there are no new messages? Thanks!
Also I have this code:
display dialog "Enter Mailbox To Check:" default answer ""
set s to text returned of result
if s = "Inbox" then s = "INBOX"
tell application "Mail"
set unreadMessages to (get every message of mailbox (s) of account "Gmail" whose read status is false)
repeat with eachMessage in unreadMessages
say "Subject."
say (get subject of eachMessage)
say "Message."
say (get content of eachMessage)
set read status of eachMessage to true
end repeat
end tell
I don't think this:
if s = "Inbox" then s = "INBOX"
is working though. If I put in "Inbox" I want it to switch it to "INBOX" instead so it'll tell me his inbox. Thanks!
Derek, try this
if s = "Inbox" then
set s to "INBOX"
end if
Cheers
if it doesn't have any new message what do i need to put in to make it say "no new messages" if there are no new messages? Thanks!
A simple if statement:
...
set unreadMessages to (get every message of mailbox (s) of account "Gmail" whose read status is false)
if count unreadMessages = 0 then
say "No new messages"
else
repeat with eachMessage in unreadMessages
-- speak stuff goes here
end repeat
end if
...
Applescript for Reading Email to me