Check for Internet Connection (1 Viewer)

AngelSpeaks

Active member
Local time
Today, 09:00
Joined
Oct 21, 2021
Messages
587
Hi All! I am working on a database that will share images by email. I have the email part working but I was wondering if there was a way to check for an internet connection before emailing the image. The database will be on my laptop and I will be at various places doing a photobooth and sometimes the WiFi isn't all that great or not available (in which case, I will save the email requests for when I get home). Some research I've done had code snippets to ping Google or some other site that is expected to be up 24/7. Any ideas? Thanks
 
Yes, ping Google. You can add another tech giant just for better confirmation.
 
Here's a Ping function...
Code:
Function Ping(ServerName As String) As Boolean
'   returns true if the server responds
'   to ping a url, remove the protcol, like https://,
'   eg: google.com
    Const PING_CMD As String = "%SystemRoot%\system32\ping.exe -n 1 -l 1 -w 500 "
    
    Ping = CreateObject("WScript.Shell").Run(PING_CMD & ServerName, 0, True) = 0
End Function
 
You can also check out this previous post.
 
I was wondering if there was a way to check for an internet connection before emailing the image.
Why?
A general internet connection is not really relevant for sending an email. - A ping to some website might work ok, even with the worst connection ever. Sending email might still fail nonetheless.
The really relevant bit is, whether your email server is available and can accept emails. The best (and only) way to find out is to try to send the email. Your code to send the email must be robust enough to fail gracefully, if something doesn't work.
 
Another option while away from home/office wifi is to use your phones hotspot.
 
Why?
A general internet connection is not really relevant for sending an email. - A ping to some website might work ok, even with the worst connection ever. Sending email might still fail nonetheless.
The really relevant bit is, whether your email server is available and can accept emails. The best (and only) way to find out is to try to send the email. Your code to send the email must be robust enough to fail gracefully, if something doesn't work.
Because I wish to tell the individual at the photo booth that the email will arrive later because of no internet. The first thing they do is check their phones for the picture so they can laugh and brag.
 

Users who are viewing this thread

Back
Top Bottom