Using C++, Windows 10, console app, Visual Studio 2019

All of the libcurl examples that I see have inline_html[] as hard coded like 

static const char inline_html[] =
  "<html><body>\r\n"
  "<p>This is the inline <b>HTML</b> message of the email.</p>"
  "<br />\r\n"
  "<p>It could be a lot of HTML data that would be displayed by "
  "email viewers able to handle HTML.</p>"
  "</body></html>\r\n";

I'm passing parameters to the main function for To, From, CC, Subject, and Body 
and want to build the inline_html[] programmatically from the Body.  I retrieve 
my Body parameter like this

std::string strBody = argv[5];

The problem that I am running into is converting the CRLFs in the string 
strBody into CRLFs in the const char inline_html[] that are acutal CR and LFs.

If I build a string for the HTML like this

std::string strNewHTML = "<html><body><p>\r\n";
strNewHTML += "<br /> \r\n";
strNewHTML += strBody;
strNewHTML += "</p></body></html>\r\n";

and convert that to const char like this

char* inline_html = new char[strNewHTML.length() + 1];
inline_html[strNewHTML.length()] = '\0';
for (int i = 0; i < strNewHTML.length(); i++) {
  inline_html[i] = strNewHTML[i];
}

I get the Body of the email that is sent without CRLF.  Just a runon block of 
text.

If, instead, I first replace the hex 0x0A in the strBody with "\n" I just get 
the text "\n".  If I replace it with an escape sequence I just get the text 
"\\n".  Same with 0x0D replacing with \r or \\r.

So what I need is to either find a way to put the CRLF into the inline_html[] 
programmatically or to create an email that is text only which would be fine 
since the email I intend to send really does not have any formatting.  

All the examples seem to always have the multipart for text and html.  I've 
been commenting out what seem to be the lines indicating html but I end up with 
a blank email.  Is there an example that I am missing for a straight text 
email.  

My current code looks very much like https://curl.se/libcurl/c/smtp-mime.html  
What would I need to comment out or change to make this text only?

I'm sure it is simple but I seem to just be going around in circles.

TIA, 
Ed



-- 
This email has been checked for viruses by AVG antivirus software.
www.avg.com
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to