Solved

Ping VB.net List Box

Posted on 2014-11-03
3
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

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.
Keystroke loggers have been around for a very long time. While the threat is old, some of the remedies are new!
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). …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

687 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