Failed to send alert: Unrecognized function or variable 'alertBody'.
10 views (last 30 days)
Show older comments
Mei Sing Wang on 7 Mar 2020
I follow the instruction in https://www.mathworks.com/help/thingspeak/analyze-channel-data-to-send-email.html?s_eid=EML_16314 However it shows that Failed to send alert: Unrecognized function or variable 'alertBody'. Anyone know why it does not recognized 'alertBody'?
Below is my code:
channelID = 995250;
alertApiKey = 'MY_ALERTS_API_KEY';
options = weboptions("HeaderFields", ["ThingSpeak-Alerts-API-Key", alertApiKey ]);
alertSubject = sprintf("Surrounding temperature and humidity");
moistureData = thingSpeakRead(channelID,'NumDays',30,'Fields',1);
alertBody = ' No data read from surrounding. ';
while humidity < 60 or temperature > 32:
alertBody = sprintf(" The weather is too hot! ", "The temperature is %0.2f",temp) ;
webwrite(alertUrl , "body", alertBody, "subject", alertSubject, options);
fprintf("Failed to send alert: %s\n", someException.message);
More Answers in the ThingSpeak Community
Find more on Execution Speed in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!