Imported from the Apple Support Forums via the Wayback Machine 🔗
I am looking for a script to connect to the internet (with dial up) external apple modem, then check email and then log off and disconnect. I don't want any other applications opening internet connect? A would use this script file with ical and could have my email checked and open up in the morning before I leave for work....being that we have dial up the entire process of connecting to the internet and checking email is time consuming. Any help is greatly appreciated. thks
tell application "Internet Connect" to connect (PPP configuration 1) to telephone number pNumber as user tUser with password tPassword
tell application "Mail" to activate -- Activate assumed e-Mail'er application.
-- tell application "Internet Connect" to disconnect (PPP configuration 1) -- Optional. Disconnect from telelphone line.
0
Camelot·
Imported from the Apple Support Forums via the Wayback Machine 🔗
You need some additional logic in there - as written, the script will launch mail, then immediately disconnect the internet connection.
At the very least you need to add a delay before disconnecting to allow for Mail to download awaiting messages.
Since you cannot predict how long a delay you'll need, a better approach would be to query Mail.app and wait until it's idle, like:
tell application "Mail"
launch -- doesn't need to be frontmost
check for new mail -- get all mail
repeat until (get background activity count) = 0
delay 2 -- wait 2 seconds before checking again
end repeat
end tell
In this way the script forces a check of new mail (don't assume that Mail.app is set to auto-check, especially for dialup users who often compose mail offline and may have automatic checking disabled), and it hangs around until Mail.app has finished downloading all the messages.