curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: SMTP without HTML or CRLF into inline_html

From: Jeffrey Walton via curl-library <curl-library_at_lists.haxx.se>
Date: Mon, 2 Jan 2023 16:11:59 -0500

On Mon, Jan 2, 2023 at 3:37 PM Ed Hardin via curl-library <
curl-library_at_lists.haxx.se> wrote:

> 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.
>

I'm guessing your problems begin early, around when the command interpreter
parses your argv[5].

I would write the body to a file, and then pass the filename through
argv[5]. In this case, you probably need a safe temporary filename to pass.
See
https://learn.microsoft.com/en-us/windows/win32/fileio/creating-and-using-a-temporary-file
.

You should also read the file in binary mode to avoid end-of-line
conversions.

Jeff


-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-01-02