Ask the Community
Groups
SendEmail() with apostrophes does not work as expected - Connect IT Community | Kaseya
<main> <article class="userContent"> <p><strong>PROBLEM</strong></p> <p>You are running Kaseya R8 or above<br>You have an agent procedure that uses the SendEmail() step.<br>You would like to use an apostrophe in the subject line.<br>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.<br>For example, the subject line in the procedure says<br><br>Subject: ERROR: ~machineid='server.customer.root' - low disk error<br><br>However, the email that you receive looks like this<br><br>ERROR: ~machineid=''server.customer.root'' - low disk error<br><br><strong>CAUSE</strong><br>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.<br><br><strong>WORKAROUND / RESOLUTION</strong><br>To work around this, do not use the apostrophe itself, but instead, use the ASCII code - &#39;<br><br>Subject: ERROR: ~machineid=&#39;server.customer.root&#39; - low disk error<br><br>This may look a little confusing, but the result will be that you get the expected email result of<br><br>ERROR: ~machineid='server.customer.root' - low disk error</p> </article> </main>