tell application "Mail"
set userAccount to "computer.ksenia.kravchenko@gmail.com"
check for new mail for userAccount
end tell
I have this AppleScript code, but I have the error: error “Mail received a mistake: It was not possible to convert “computer.ksenia.kravchenko@gmail.com” to account type.” number -1700 from “computer.ksenia.kravchenko@gmail.com” to account
How I can fix it??
Is there an account “computer.ksenia.kravchenko@gmail.com” ?
also userAccount is set to a string, not an account
try this line…
tell application "Mail"
set userAccount to account "computer.ksenia.kravchenko@gmail.com"
check for new mail for userAccount
end tell
1 Like
The code below checks for new mail and returns the account your e-address is configured for.
tell application "Mail"
set my_addr to "computer.ksenia.kravchenko@gmail.com"
repeat with anObj in accounts
set my_mailaddr to anObj's contents's email addresses
if my_addr is in my_mailaddr then
check for new mail for anObj's contents
exit repeat
end if
end repeat
get anObj's contents
end tell
1 Like
Thank you so much! It works!
This caught my interest this morning (still learning, so I try things I find here).
Although it seems to work for the original poster, the script posted by “robertfern” returns an error, "Mail got an error: Can’t get account “myname@yahoo.com”.
The script posted by “scrutinizer82” runs, opens the Mail app and seems to work just fine.
Any idea as to why that may be?
Because :computer.ksenia.kravchenko@gmail.com is not the actual name of your account
But I changed it as so:
tell application "Mail"
set userAccount to account "myname@yahoo.com"
check for new mail for userAccount
end tell
FWIW, I tested both Robert’s and scrutinizer82 scripts, and they both worked fine. I would normally expect the account name and the account’s email address (or addresses) to be different.
Trying to follow along here and “I would normally expect the account name and the account’s email address (or addresses) to be different” is giving me a clue.
So, in the Mail app the account name is “First Name & Last Name.” The email address is “lastname@yahoo.com.”
No matter how I put that combination together, with periods/without periods, with quotes/without quotes, I still get errors. I’m missing something pretty basic here but have no idea what it might be.
Homer712. With the Mail App open, I select Mail > Settings then the Accounts tab (see partial screenshot below). I used Google One in Robert’s script and my email address in scrutinizer82’s script. I’m running macOS Sonoma.
I wonder if it’s possibly because I have “SpamSieve” installed?