7 Replies Latest reply on Dec 29, 2017 8:27 PM by gsee RSS
    gsee Apprentice

    Alert subscription stopped sending emails



    I have a subscription to an alert that has stopped sending emails. The subscription to AnyAlert is enabled on a Thing Template, and the alerts are enabled on the appropriate Things. The subscription code is:


    sensorMessage = eventData.description + " at Sensor " + me.SensorID;
    linkMessage = "You can view the status of all sensors locations here."
    var params = {
        cc: "username@gmail.com",
        subject: me.SensorName + " alert" /* STRING */,
        from: "username@company.com" /* STRING */,
        to: me.ThingManager.smsAddress,
        body: "At "+ eventTime + " " + sensorMessage + "<br>" + linkMessage,


    The alerts were sending emails correctly a week ago. I acknowledged a few of the alerts in the monitor, but not all, and added several new alerts that are still not sending emails, although I can see the new alerts in the Alert Summary.


    I'd appreciate any help!


      • Re: Alert subscription stopped sending emails
        ewertonm Creator

        Hi Gloria,


        Do you see any error in the logger (Monitoring->Logs->Script) ?


        What would  do is to add a logger.warn("Executed"); statement in the code just to figure out if the service is running and it is not the Mail Server that is holding the message from being sent (if you haven't done it yet)




          • Re: Alert subscription stopped sending emails
            gsee Apprentice

            Thanks Ewerton. That narrowed it down a lot.

            I added a couple logger statements, and it turns out the me.ThingManager.smsAddress is coming back undefined. Any suggestions on how to pull the sms or email for a user defined as a property of each Thing? I can get it to work for a hardcoded email or sms address (or hard coded user) but that's not scalable to multiple users.

              • Re: Alert subscription stopped sending emails
                ewertonm Creator

                I think you could use the GetPropertyValues from the User Object once you retrieve the user name. Maybe it is not the elegant way to do it, but I did it and it did the trick:


                var userProperties = Users[me.user].GetPropertyValues();





                Where me.user is a variable of the type USERNAME that I used to select an user.


                Not sure if this is your exact use case tough.





                Actually you don't even need the Get Property Values call. Just make it an indirect reference:







            • Re: Alert subscription stopped sending emails
              fmanniti Creator

              Sorry for re-opening this post but I am having the same issue.

              I have a thing with a property called isSeismic (boolean); if it is true, an alert should be triggered and I have a subscription which runs my service for sending email.

              This is the path.

              The event comes  --> Stream add a entry  --> at stream entry an event is triggered to Thing  --> Thing has subscription to call EmailThingSender --> EmailThingSender sends email.


              My code is:

                  var subject = Resources["RuntimeLocalizationFunctions"].GetEffectiveToken({token: 'NewAlertNotification'});
                  var configurator = Things[structureName].Configurator;
                  var configuratorProperties = Users[configurator].GetPropertyValues();
                  var confEmail = configuratorProperties.emailAddress;
                  var params = {
                      to: confEmail,
                      subject: subject,
                      from: 'alert.notification@gmail.com',
                      body: getBodyMail()


              If I manually change the property Value (I switch isSeismic to true), the email notificator works, but if I do it as an event subscription, it doesn't