This is I am sure simple, but I can't seem to figure out how to insert a variable in to an email text. I am using an esp8226 board and sending email with smtp. I am having no issues sending text within the email for example:
String htmlMsg = "<div style=\"color:#2f4468;\"><h1>Did you get this email? The time is 4:54</h1><p>- Sent from ESP board</p></div>";
message.html.content = htmlMsg.c_str();
message.html.content = htmlMsg.c_str();
message.text.charSet = "us-ascii";
message.html.transfer_encoding = Content_Transfer_Encoding::enc_7bit;
But I can't figure out how to put a variable that I have within the code in to the email that is sent out. I am able to put a variable on to a web server by using the client.println (variable); . How do I do this in an email sent out?
I can post the entire code if necessary, but I figure it is something simple....
Here is the email function I am using:
void Testemail1()
{
smtp.debug(1);
smtp.callback(smtpCallback);
ESP_Mail_Session session;
session.server.host_name = SMTP_HOST;
session.server.port = SMTP_PORT;
session.login.email = AUTHOR_EMAIL;
session.login.password = AUTHOR_PASSWORD;
session.login.user_domain = "";
SMTP_Message message;
message.sender.name = "Dehumidifier Message";
message.sender.email = AUTHOR_EMAIL;
message.subject = "Email Test";
message.addRecipient("", RECIPIENT_EMAIL);
String htmlMsg = "<div style=\"color:#2f4468;\"><h1>Did you get this email? The time is 4:54</h1><p>- Sent from ESP board</p></div>";
message.html.content = htmlMsg.c_str();
message.html.content = htmlMsg.c_str();
message.text.charSet = "us-ascii";
message.html.transfer_encoding = Content_Transfer_Encoding::enc_7bit;
if (!smtp.connect(&session))
return;
if (!MailClient.sendMail(&smtp, &message))
Serial.println("Error sending Email, " + smtp.errorReason());
TestEmail = true;
}
Thanks!