function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Need help in setting subject for Outbound Email



I have a trigger that sends notifications to a specific gmail id  whenever a email message is received in a case or sent from the case. I have a used a fixed template for setting the Subject for these notification emails such that they form a conversation thread for each case in the gmail account. This has been working correctly untill now when we received an email that had special caracters in the subject line.


The scenario is a customer sent an email with some foriegn characters in the subject line, this email created the case and the case subject also has these foriegn characters in them. The email message triggers the notification email. Upon receiving the notification our support person replied to the customer from the case. This email also triggered the notification. But both these email have come in as seperate threads instead of one.


The code that I use for setting the subject line is as follows

mail.setSubject('SR ' + listC[0].CaseNumber + ' [' +listC[0].Subject+ ']');

In gmail using the "Show Original" feature I could see the Subject line of the notification sent in a proper scenario where they are threading properly

Subject: SR 04113 [LAG hashing issues]

In gmail using the "Show Original" feature the Subject line for the notification with special charcters are as follows

this is when the notification was sent for the customer's email

Subject: =?ISO-8859-1?Q?SR_04116_[Re:_=3FSFG=3FSSH,Telnet]?=

this is when the notification was sent for the support persons email

Subject: =?UTF-8?Q?SR_04116_[Re:_=E3=80=90SFG=E3=80=91SSH,Telnet]?=


Please help me in understanding why would there by 2 types of subject line when the code that sends the email notification is common. How do I fix this so that it does not create new threads?