Solved

Ping VB.net List Box

Posted on 2014-11-03
3
257 Views
Last Modified: 2014-11-25
Good Morning,

I'm trying to figure something out. I have this code below that will ping a system in my listbox (If its selected) . if the ping is successful then it will send me an email.

What I'm trying to do is loop through ALL the systems in the list box "continuously". Can someone please help me with this?

        Try

            If My.Computer.Network.Ping(Systems.SelectedItem) Then
          
                Try
                    Dim Smtp_Server As New SmtpClient
                    Dim e_mail As New MailMessage()
                    Smtp_Server.UseDefaultCredentials = False
                    Smtp_Server.Credentials = New Net.NetworkCredential("user@gmail.com", "Password")
                    Smtp_Server.Port = 587
                    Smtp_Server.EnableSsl = True
                    Smtp_Server.Host = "smtp.gmail.com"

                    e_mail = New MailMessage()
                    e_mail.From = New MailAddress("name@gmail.com")
                    e_mail.To.Add("name@ccp.edu")
                    e_mail.Subject = "System Status"
                    e_mail.IsBodyHtml = False
                    e_mail.Body = "The system is Online"
                    Smtp_Server.Send(e_mail)
                    MsgBox("Mail Sent")

                Catch error_t As Exception
                    MsgBox(error_t.ToString)
                End Try
            Else

            End If
        Catch ex As Exception

        End Try

Open in new window

0
Comment
Question by:AnthonySmithMCP
  • 2
3 Comments
 
LVL 12

Assisted Solution

by:ktaczala
ktaczala earned 500 total points
ID: 40421359
you need to get the count from the list box and then loop on that.
So outside the ping do a
DO ... UNTIL this gives you the option to stop it.
inside the DO ... UNTIL use a FOR ... EACH to select each listbox item.
then inside the FOR ... EACH insert your ping & email code.
Put the ping code inside a background worker thread otherwise it'll seem like it's locked up.
0
 
LVL 1

Accepted Solution

by:
AnthonySmithMCP earned 0 total points
ID: 40455405
Instead i downloaded a network pinger
0
 
LVL 1

Author Closing Comment

by:AnthonySmithMCP
ID: 40464097
No one could answer my question.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Azure network security group 2 58
Trouble with References... 5 54
Firewall port opening 2 67
Extra security implementation for 2017 9 52
This subject  of securing wireless devices conjures up visions of your PC or mobile phone connecting to the Internet through some hotspot at Starbucks. But it is so much more than that. Let’s look at the facts: devices#sthash.eoFY7dic.
Getting hacked is no longer a matter or "if you get hacked" — the 2016 cyber threat landscape is now titled "when you get hacked." When it happens — will you be proactive, or reactive?
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question