0

Prior to 10.7.x this AppleScript used to work with AppleMail:

tell application "Mail"
   activate
   check for new mail
   repeat until (background activity count) = 0
       do shell script "sleep 1"
   end repeat
end tell

However, since 10.7.x+ this does not seem to work anymore. It doesn't even go in to the repeat loop. My guess is that AppleMail has changed the way it downloads emails and doesn't use "background activity" anymore.

Anyone know how to wait for all emails to download in AppleMail 5+ with AppleScript?

thiesdiggity
  • 1,897
  • 2
  • 18
  • 27
  • Does this script still work for you? When I try to use `background activity count` I get an error message, see https://stackoverflow.com/questions/74249201/applescript-mail-apps-property-background-activity-count-is-broken – d-b Oct 30 '22 at 08:04

1 Answers1

1

I checked on 10.8.2 and it worked. Maybe the check is really fast on your system and it's already finished when the repeat until condition is evaluated. But I can't understand what's the objective of the script. Also, it would be better if you replace the do shell script "sleep 1" with a simpler delay 1.

Michele Percich
  • 1,872
  • 2
  • 14
  • 20