Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Katriel

Pages: [1]
1
Application Showcase / Email Alerts
« on: March 13, 2018, 05:59:21 PM »
I just followed the instructions and set up some email alerts for "failed red rabbits" which is when we verify our poka yokes are working correctly.  This was to try to catch if someone accidentally "fixes" a machine rather than notice the component was missing.  Here is a small amount of the 1000+ lines of code for all the faults at my plant.  This was NOT my development but just came from samples I found here (thanks Archie) and because there are about 100 email messages, I set it up as a subroutine and pass the subject and body in to match where it was called from.  For me, it is an exciting beginning, for many, it is like watching a baby trying to stand up.

   Private Sub DataSubscriber68_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber68.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

                SendEmailMessage("F RH ST485 FAILED RED RABBIT")

 

            End If

        End If

    End Sub

    Private Sub DataSubscriber69_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber69.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

                SendEmailMessage("F LH ST390 FAILED RED RABBIT")

 

            End If

        End If

    End Sub

 

    Private Sub DataSubscriber70_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber70.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

                SendEmailMessage("F LH ST485 FAILED RED RABBIT")

 

            End If

        End If

    End Sub

 

 

 

 

    Private Sub SendEmailMessage(subject As String)

        Using email As New System.Net.Mail.MailMessage

            '* Set who it is from

            email.From = New System.Net.Mail.MailAddress("EmailAccount@Company.com")

 

            '* Add the recipients

            email.To.Add(New System.Net.Mail.MailAddress("Name_of_Group@Company.com"))

 

            email.Subject = subject

            email.Body = subject

 

            '* Create the client that will send the message

            Dim MailSendingClient As New System.Net.Mail.SmtpClient

            '* set this to the smtp server you will use

            MailSendingClient.Host = "Address of mail server"

            MailSendingClient.Port = port of mail sending server

 

            '* If your SMTP Server does not require a password, then remove this section

            'Dim credentials As New System.Net.NetworkCredential("email@domain.com", "password")

            'MailSendingClient.Credentials = credentials

            'MailSendingClient.EnableSsl = True

 

            '* Send the email

            MailSendingClient.Send(email)

        End Using

    End Sub


Pages: [1]