Announcement

Collapse
No announcement yet.

Vb.net script to send an email

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Vb.net script to send an email

    I'm using Raspbian Stretch with Mono 5.2 on a Raspberry Pi 3. I've created an event where if an alarm is triggered the event will run a vb.net script to send an email to advise what zone was triggered.

    The trigger in the event is working fine but the log is advising that the script is running in the background every two minutes. It looks like the script is trying to send the email with no success. Below is a copy of the script. Is there anybody that can see anything obviously wrong with the script that is preventing the email from being sent.

    Sending of emails in HS is working fine so credentials are not an issue.

    Public Sub Main(ByVal Parm As Object)
    Dim AlarmType, Parms() as String
    Parms = split(Parm, ",")
    ' Change device string if it's been renamed'
    Dim LZname as String = "System Last Zone Faulted"
    Dim LZref as integer = hs.DeviceValueByName(LZname)

    if (LZref > 0) then
    Dim dv as Scheduler.Classes.DeviceClass
    dv = hs.GetDeviceByRef(LZref)

    Dim ZoneName as String = dv.Name(hs)
    Dim emsg as string = Parms(0) & " received for " & ZoneName
    hs.SendEmail("joebloggs@gmail.com","maryjane@gmail.com",""," ","Alarm Recieved",emsg,"")
    end if

    End Sub

    #2
    silly question..
    can you send an email with a test event that uses the built in email function? I know it was a pita for me to get that working first.. but I wonder if that needs to be set, then you can use a vb to send emails???

    here is one of mine as an example..

    I also use gmail...
    Attached Files
    HW - i5 4570T @2.9ghz runs @11w | 8gb ram | 128gb ssd OS - Win10 x64

    HS - HS3 Pro Edition 3.0.0.435

    Plugins - BLRF 2.0.94.0 | Concord 4 3.1.13.10 | HSBuddy 3.9.605.5 | HSTouch Server 3.0.0.68 | RFXCOM 30.0.0.36 | X10 3.0.0.36 | Z-Wave 3.0.1.190

    Hardware - EdgePort/4 DB9 Serial | RFXCOM 433MHz USB Transceiver | Superbus 2000 for Concord 4 | TI103 X-10 Interface | WGL Designs W800 RF | Z-Net Z-Wave Interface

    Comment


      #3
      Not sure where you're coming from here. As I mentioned in the original post the internal email sending function works in HS. I tried you're sample event and it works fine.

      The problem for me seems to be buried in the script. A syntax error, a missing bracket or comma possibly. Bear in mind I'm using Raspbian Stretch with Mono 5.2 and NOT Windows. I'm wondering if the vb.script will work with this setup

      Comment


        #4
        whelp sorry no help
        HW - i5 4570T @2.9ghz runs @11w | 8gb ram | 128gb ssd OS - Win10 x64

        HS - HS3 Pro Edition 3.0.0.435

        Plugins - BLRF 2.0.94.0 | Concord 4 3.1.13.10 | HSBuddy 3.9.605.5 | HSTouch Server 3.0.0.68 | RFXCOM 30.0.0.36 | X10 3.0.0.36 | Z-Wave 3.0.1.190

        Hardware - EdgePort/4 DB9 Serial | RFXCOM 433MHz USB Transceiver | Superbus 2000 for Concord 4 | TI103 X-10 Interface | WGL Designs W800 RF | Z-Net Z-Wave Interface

        Comment


          #5
          Try replacing:

          Parms = split(Parm, ",")

          With:

          Parms = Parm.split(",")

          The first is a visual basic command.
          Jon

          Comment


            #6
            Originally posted by jon00 View Post
            Try replacing:

            Parms = split(Parm, ",")

            With:

            Parms = Parm.split(",")

            The first is a visual basic command.
            Did that jon00 and got the following in the log

            Error Compiling script /home/pi/HomeSeer/scripts/AlarmTrigger.vb: Function without an 'As' clause; Object return type assumed.
            Dec-07 21:15:44 Error Compiling script /home/pi/HomeSeer/scripts/AlarmTrigger.vb: Value of type 'Object' cannot be converted to 'System.String[]'.
            Dec-07 21:15:44 Error Compiling script /home/pi/HomeSeer/scripts/AlarmTrigger.vb: The import 'System.Core' could not be found.
            Dec-07 21:15:44 Error Compiling script /home/pi/HomeSeer/scripts/AlarmTrigger.vb: Function without an 'As' clause; Object return type assumed.
            Dec-07 21:15:44 Error Compiling script /home/pi/HomeSeer/scripts/AlarmTrigger.vb: Value of type 'Object' cannot be converted to 'System.String[]'.
            Dec-07 21:15:44 Error Compiling script /home/pi/HomeSeer/scripts/AlarmTrigger.vb: The import 'System.Core' could not be found.

            Comment


              #7
              Problem solved thanks to vasrc.

              I had the string named System Last Zone Faulted named incorrectly. I should have named it to Security Last Zone Faulted to reflect my devices name.

              Script is working fine now. Thanks to all for your input.

              Comment

              Working...
              X