Hardware Reference
In-Depth Information
SendEmailChoreo.setSavedInputs("arduinoTemperatureEmail");
We will now build the body of the e-mail, which will be stored in a string variable. We
simply use a generic message where we attach the value of the measured temperature and
store everything in a string. Finally, we will add the following lines as an input to the
Choreo used to send e-mails:
String MessageBodyValue = String("Alert! The current sensor
value is: ") + String(sensorValue);
SendEmailChoreo.addInput("MessageBody", MessageBodyValue);
Just before executing Choreo, we define that we want to use SendEmailChoreo from
Gmail using the following line:
SendEmailChoreo.setChoreo("/Library/Google/Gmail/
SendEmail");
We can finally execute Choreo and store the result in a variable:
unsigned intreturnCode = SendEmailChoreo.run();
As in the previous section, if the result is 0 , it means everything went fine. If this is not
the case, we will print the error message on the Serial port for debugging using the fol-
lowing piece of code:
if (returnCode == 0) {
Serial.println("Done!\n");
} else {
// A non-zero return code means there was an error
// Read and print the error message
while (SendEmailChoreo.available()) {
char c = SendEmailChoreo.read();
Serial.print(c);
}
Serial.println();
}
Finally, we will close Choreo with the following line:
SendEmailChoreo.close();
Search WWH ::




Custom Search