12
« on: November 29, 2016, 11:26:42 PM »
worked first time, thank you so much
here is the code i used to get gmail to work, I pieced it together from a few different sources. It requires gmail to have an app password through 2 step verification
i am not very good with vb so dont laugh if there is mistakes,,, i am good at cut and paste
Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged
'* Make sure Data came back
If e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then
'* Did it come back as True or 1?
If String.Compare(e.Values(0), "TRUE", True) = 0 Or e.Values(0) = "1" Then
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.EnableSsl = True
SmtpServer.Credentials = New _
Net.NetworkCredential("youremailaddress@gmail.com", "apppassword")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("someone@gmail.com")
mail.To.Add("someone@yahoo.com")
mail.Subject = "Test Mail"
mail.Body = "The Temp of the water is " & EthernetIPforSLCMicroCom1.Read("N7:0")
SmtpServer.Send(mail)
MsgBox("mail send")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
End If
End Sub