Blynk.timer and variable in Mail

Hi, i use the following function for timer

    void myTimerMail() //16 sec
      if (sensorAlarm) {"Subject: Button Logger", "You just pushed the button.");
  timer.setInterval(16000L, myTimerMail);

This code is running well.
How can i include the variable ‘sensorID’ into the mail body?

The next question is: did this timer run automaticaly every 16 cec? or must i call “myTimerMail()” that he send the mail directly by up coming event, because the variable sensorID have only a few seconds the value.

Have the timer a function that the mail will send only one time and when the next event is coming up send the next mail. Or must i handle this in a new function?

Thankyou for your help from a newbee

You haven’t shared enough of your sketch for us to know where ‘sensorID’ is coming from and whether it’s a local or global variable. Assuming it’s a global variable you can use the method shown in this example:

It’s worth reading the documentaion here:

so that you understand the limitations regarding the maximum number of characters and the naximum frequency.

Yes, provided you have in your void loop.


Hi Pete, thankyo for answer.
yes sensorID is global
yes i let the timer runing in void loop; // Initiates BlynkTimer
so i understand, i must build a string with text and variables and than send it in the mail, is this correct?
or is their another way to put a variable value directly in the mail body and i dont know the syntax?

That’s the way it’s done in the example.

I don’t know. Maybe you should experiment a little and see what happens.