Solved

Ping VB.net List Box

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

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…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
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…

867 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

24 Experts available now in Live!

Get 1:1 Help Now