Help with Blynk.email

hello i need help on getting this to work is it a String, Char, etc:

void Send_Email(){
  char t1[EMAIL.length() +1];
  char t2[NAME.length() +1];
  String t3 = "Your water alarm " + NAME + " has detected water";
  char t4[t3.length()+1];

  EMAIL.toCharArray(t1, EMAIL.length());
  NAME.toCharArray(t2, NAME.length());
  t3.toCharArray(t4, t3.length());
  Blynk.email(t1, t2, t4);
}

Hello.

I think it should be

String t3 = String("Your water alarm ") + NAME + " has detected water";

But this code still looks complicated. I recommend you to google something like “Arduino concat string”

@Dmitriy, thanks but im still getting this error

exit status 1
no matching function for call to 'BlynkWifi::email(char [(((sizetype)<anonymous>) + 1)], char [(((sizetype)<anonymous>) + 1)], char [(((sizetype)<anonymous>) + 1)])'

does it work if you instead do:
Blynk.email(String(t1), t2, String(t4));

maybe the Blynk.email() function requires all string parameters…
Gustavo.

No it still errors out

@FunguyPro to debug this do the following:

Before char t1[EMAIL.length() +1]; enter:

  String EMAIL = "costas@home.com";
  String NAME = "Costas";

Blynk.email(t1, t2, t4) enter:

  Serial.print(t1);
  Serial.print(">");
  Serial.print(t2);
  Serial.print(">");
  Serial.println(t4);

You will see:

costas@home.co>Costa>Your water alarm Costas has detected wate

t1, t2 and t4 are all 1 character short.

This code compiles and email is received:

  char emailaddress[20] = "costas@xxxx.com";
  char emailsubject[20] = "Email from Blynk";
  String myname = "Costas";
  String one = "hi there ";
  String two = " are you ok?";
  String three = one + myname + two;
  Serial.print("Sending email to ");
  Serial.print(emailaddress);
  Serial.print(" with subject of ");
  Serial.print(emailsubject);
  Serial.print(" and message of ");
  Serial.println(three);
  Blynk.email(emailaddress, emailsubject, three); 

Serial Monitor:

Sending email to costas@xxxx.com with subject of Email from Blynk and message of hi there Costas are you ok?

1 Like

OK thank you, that worked :smile: @Costas