0

In a c-ish language, I was instantiating a MSScriptControl.ScriptControl object and using the .AddCode method to run VBScript, which in turn, instantiated the CDO.Message object.

However, every time I got to the "objMsg.HTMLBody = \"" + email_body + "\" \n" (note this was in the c, the VBScript would be: objMsg.HTMLBody = email_body line of the code, I got an error

Microsoft VBScript compilation error : Unterminated string constant

Keith
  • 777
  • 8
  • 27

1 Answers1

0

Eventually, I found the problem was that the variable email_body contained character 10 (\n) in it (several places), which was interpreted in VBScript as the end of a line of code (but before a close-quote), which is a syntax error.

I can't imagine I'm the only person to miss this, so I'm writing a little 'knowledge base' here.

Resolution: In the parent-language (in this case, a weird form of c called hsl), use a string-replace method to replace all inctances of \n with <br> and it works just fine now, such as: StrReplace(email_body, "\n", "<br>"

then call the ScriptControl.AddCode( ... ); method.

Keith
  • 777
  • 8
  • 27