The <<HERE is a feature of the shell; you need to spawn a shell to get it working.
Code:
sprintf (cmd, "sh -c 'elm -s SUBJECT %s <<HERE\n"
"%s\n[include %s text/plain base64]\nHERE\n'"l, emailAddr, sMailBody, sFileName);
You are not allowed any leading whitespace on the line containing the terminating HERE (at least not in many shells).
Couldn't you just open a pipe to "elm -s SUBJECT %s" with popen() and pipe in the content yourself, though? That's pretty much equivalent to using a HERE document. (And you avoild the pesky security considerations you always bump into when spawning a shell with user-supplied input.)
If the file truly is text/plain, what's the benefit of encoding it in base64, by the way?