Solved

Ping VB.net List Box

Posted on 2014-11-03
3
241 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now