Email string variable

Is it possible to use a string variable instead of a text between quote? I tried it but it does not work.

String emailmessage;
emailmessage="This is a test";
Blynk.email("test@gmail.com", "Blynk", emailmessage);

@michel.richir I was pretty sure String was ok but you could:

char emailmessage[];

If this fails I can check some of my projects or you have a bug in your sketch that prevents the email being sent.

Convert to String like below

String emailmessage;
emailmessage="This is a test";
Blynk.email("test@gmail.com", "Blynk", String(emailmessage));

Strangely enough, I tested again my original code changing the email address to a non gmail account. It works.

Not necessary to redeclare “emailmessage” as a string…

Hi, how would I add a Carriage Return and Line Feed in die String(emailmessage)?

You can use html formatting:

I use the following:

emailmessage = “this is line 1
”;
emailmessage = emailmessage + “this is line 2
”;
Blynk.email(emailto, subject, emailmessage);

Hi Michel,

Thanx for the info. Just try it but is missing something…

When I use the following code:

emailBody = “first line.”;
emailBody = emailBody + “second line…”;
Blynk.email(String(emailSubject), String(emailBody));

The string gets printed on one line within the message.

When I use the following:

emailBody = "first line.
";
emailBody = emailBody + “second line…”;
Blynk.email(emailSubject, emailBody);

I’m getting a compile error “missing terminating " character” …

Even trying something like this don’t work…

emailBody = “first line.”;
emailBody = emailBody + “\n” + “\r”;
emailBody = emailBody + “second line…”;
Blynk.email(emailSubject, emailBody);

Any other suggestions?

Email is HTML so if you what to break the line you need to use <p>

Thank you @ldb that worked!!!

Now for the rest of my challenges… :worried::robot: