sent email if ping failed on listview VB.net : I'm creating the Ping monitoring system using VB.net. I want the system to sent an email if some of device is down, and sent an email again if that device back to online. I try to create this script but it failed. Can u all help me to solve the problem. The email will always sent if the device ping is failed.
I used Ping to monitor the devices, IP Address of the device already saved and will be loaded on lvi.SubItems(5).Text.

Here is the script
   
    Private Sub Ping_LV()
        For Each lvi As ListViewItem In LV_Monitoring.Items
            Dim p As New Ping
            AddHandler p.PingCompleted, AddressOf p_PingCompleted
            p.SendAsync(lvi.SubItems(5).Text, lvi)
        Next
    End Sub

    Private Sub p_PingCompleted(ByVal sender As Object, ByVal e As System.Net.NetworkInformation.PingCompletedEventArgs)
        Dim p As Ping = DirectCast(sender, Ping)
        Dim lvi As ListViewItem = DirectCast(e.UserState, ListViewItem)

        If e.Reply.Status = IPStatus.Success Then
            Console.WriteLine("Ping Success")
            lvi.SubItems(6).Text = "UP"
            lvi.UseItemStyleForSubItems = False
            lvi.SubItems(6).ForeColor = Color.White
            lvi.SubItems(6).BackColor = Color.Green
        Else
            Console.WriteLine("Ping Failed")
            lvi.SubItems(6).Text = "DOWN"
            lvi.UseItemStyleForSubItems = False
            lvi.SubItems(6).ForeColor = Color.White
            lvi.SubItems(6).BackColor = Color.Red
            Sent_Email()
        End If

        RemoveHandler p.PingCompleted, AddressOf p_PingCompleted
        p.Dispose()
        LV_Monitoring.Refresh()

    End Sub