Email Subject/Body/To etc. Fields Improperly Parse Quotes

I'm trying to send e-mails using SMTP.
Very simple e-mails work, but once more complex code is included they break. It seems like certain quote characters are not handled correctly.

I see messages like this in the Retool console:

SendEmail failed (0.002s):JSON.parse: expected ',' or '}' after property value in object at line 1 column 38 of the JSON data

For example, the following body of a email DOES NOT work, even though the editor "likes" the syntax and shows the expected string in the "green box".

Hi {{current_user.firstName + " " + current_user.lastName}}, this is a "bad" email

The following body of an email DOES work, even though the editor thinks it's a syntax error.

Hi {{current_user.firstName + " " + current_user.lastName}}, this is a "good" email

Could you share a screenshot of each case? One for an email that works and one that doesn't. It would be great to see the code that breaks it on a screenshot.

Oh, sorry for the confusing post. I think the escape characters got messed up somehow...

Here's a non working email.
bad

Here's a working email.
good

No worries! :slightly_smiling_face:

That's odd. What happens if on the Body we do:
Hi {{current_user.firstName}} {{current_user.lastName}} ...
Does this also fail?

Nope, that works fine.

Sweet! On the other hand, I tried reproducing the error by running this query:

And I had no issues sending/getting the email.

Aha! I found it, just use single quotation marks on the Body. It looks like when the Body is parsed, the {{ }} is already turned into a double quotation mark string, which is causing the issue.

Yea, that's another workaround.
Correct me if I'm wrong, but that's not the behavior in other places in Retool.

If it's intended to work that way, then the syntax highlighting and "green box" preview should make that clear.

That is correct, this is definitely a bug. We created a bug report internally and we'll let you know when it is fixed. On the meantime, use the workaround you like the most. :slightly_smiling_face:

Thank you for flagging this issue!