Follow

SendEmail() with apostrophes does not work as expected

PROBLEM

You are running Kaseya R8 or above
You have an agent procedure that uses the SendEmail() step.
You would like to use an apostrophe in the subject line.
When attempting to do this, you find that the subject of the email that you receive has two apostrophes instead of the single one that you expected.
For example, the subject line in the procedure says

Subject: ERROR: ~machineid='server.customer.root' - low disk error

However, the email that you receive looks like this

ERROR: ~machineid=''server.customer.root'' - low disk error

CAUSE
Certain inputs are escaped to remove SQL injection possibilities. Because apostrophes are valid SQL code, they are surrounded by additional apostrophes to avoid any issues.

WORKAROUND / RESOLUTION
To work around this, do not use the apostrophe itself, but instead, use the ASCII code - '

Subject: ERROR: ~machineid='server.customer.root' - low disk error

This may look a little confusing, but the result will be that you get the expected email result of

ERROR: ~machineid='server.customer.root' - low disk error

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.