Solved

Ping VB.net List Box

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nipper studio 2 53
Question to Pivot table 1 66
Another machine has a duplicate ip? 11 39
Quick start reading for Windows sysinternals 5 41
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
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…
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…

679 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