Detect if user connected to the Internet?


I would like to know how to detect if a user is connected to the Internet.
I would like to send an email via SMTP, but needs to know if the user is connected beforehand.

If user the is not connected, how do I bring up the Connect to the Internet Dialog Box?