SendEmail Subject is only a single word

When I am using SendEmai, the Subject is only using the 1st word of the entire subject. What could cause this? Below is the relavant code. The subject of the email results in being ‘Payment’. If I change the value of LSubject to be = ‘Batch Payment: …’, the subject becomes ‘Batch’.

Local LToEmail, LSubject, LBody, LLocationName, LTableText, LPPSNum, LTotalPaid, LSubject
LSubject = "Payment Batch: #" + GBatchNumber

SendEmail {smtp=[]( From="[](" FromName="Perfect Pour PM" To=}+ LToEmail + { ToName="Bar & Grill" Subject=} + LSubject, LBody

You need to put quotes around your subject. With the code you are using, probably the easiest way would be to use the quoted( function:

... Subject=} + quoted(LSubject), LBody

Is there a simple explanation for why?

Because it contains spaces. The command’s options consist of multiple parameters separated by spaces in the form:

option=argument option=argument option=argument . . .

If the argument contains one or spaces it needs to be quoted, otherwise its second word will be assumed to be the next option. Thus Subject=Topic, Subject="Topic" and Subject="Next topic" are OK, but Subject=Next topic is taken to mean Subject=Next, while topic is ignored as an invalid option.

There are many statements that work like this with multiple option/value pairs packed into a single parameter. As long as the value contains no spaces or punctuation, no quotes are needed.

{option=value option=value option=value}

But if a value contains spaces or punctuation, it must be delimited with quotes so that Panorama knows where the value begins and ends.

{option=value option="multi word value" option=value}

Of course it’s ok to use the quotes even if the value doesn’t contain spaces or punctuation.

{option="value" option="multi word value" option="value"}

Keep in mind that a value could itself contain the = symbol, like this.

{option="value" option="a=b" option="value"}

So the " is needed to eliminate any ambiguity.

As I was typing this @pcnewbie also posted the correct answer, thanks!