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

How to use the setInReplyTo option in Single Email Message



I am trying to use the setInReplyTo option in single email message to solve a conversation threading problem. I am querying for an emailmessage and then setting that Id as value for the method. I am encountering run time errors with this


System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_MESSAGE_ID_REFERENCE, In-Reply-To header is not valid.: []


I am not sure how to set this up to work. Please help.




Imran MohammedImran Mohammed

It could be the format issue. You can find some info on messaging format in the below link.

Click Here


setInReplyTo takes String argument type. You have to convert the id into string through string.valueof(ID).


Hope this helps.


Siva Kumar VadlaSiva Kumar Vadla
Can you tell me what your passing as a parameter to setInReplyTo(?) from EmailMessage.
Manoj ThangavelManoj Thangavel
Hi Siva, any idea what should we set setInReplyTo? Are you able to sort it out?
Juan Jardim 14Juan Jardim 14
For anybody that is looking for an answer, you need to use the 'MessageIdentifier' of the EmailMessage and not the salesforce ID