I’ve got a simple script which opens a dial-up connection, checks for new mail in mail.app, closes the connection and reports some results. But: I can’t figure out a simple way of determining when the download of new mail is complete, in order to trigger the
tell application "Internet Connect" to disconnect configuration config_name
statement. The “check for new mail” command in mail.app doesn’t seem to create a result. And my clunky alternative (using bytes received of status of state of configuration, etc.) fails to distinguish between mail and other downloads!
Is there a simple way to monitor when mail.app has completed downloading mail??? Suspect I’m overlooking something very obvious…
The Mail application has a property which might be useful. I don’t know if it is a good indicator or not.
background activity count integer [r/o] – (inherited from the application class)
Number of background activities currently running in Mail, according to the Activity Viewer.
set bgCount to 1
repeat until bgCount is 0
tell application "Mail"
set bgCount to background activity count
end tell
delay 10 -- seconds between checks
end repeat
if bgCount is 0 then
display dialog "Nothin' happenin' in Mail." -- for demo only
-- tell application "Internet Connect" to disconnect configuration config_name
end if
Here is the result and I thanks the help
================== HERE IS THE SCRIPT ====
set bgCount to 1 – Va servir de compteur d’activité
tell application “Internet Connect” – Activation de la connexion Internet pour le compte actif
activate
activate
connect
tell application "Mail" -- Ouverture de l'application Mail
activate
check for new mail -- test de l'existence de nouveaux mails
repeat until bgCount is 0
-- check for new mail -- test de l'existence de nouveaux mails -- mieux en dehors de boucle ???
delay 10 -- entre chaque appel de check for new mail
set bgCount to background activity count -- s'il n'y a plus d'activité, alors mettre le drapeau à 0
end repeat
quit application "Mail"
end tell
disconnect application "Internet Connect"
quit application "Internet Connect"