Hello Everyone, In this tutorial, I am going to provide a code example that explain you, how to get thread id of email-to-case in apex. You can use this thread id in your email body to log customer email in single case id, when he replying on email. So, let’s begin,
Thread Id of Case
ID orgId = UserInfo.getOrganizationId(); String sOrgId = (string)orgId; ID caseId = caseId; \\ replace this with your case id String sCaseId = (string)caseId; String threadIdPart1 = 'ref:_' + sOrgId.left(5) + sOrgId.right(10).replace('0',''); threadIdPart1 = threadIdPart1.substring(0,threadIdPart1.length()-3); String threadIdPart2 = '._' + sCaseId.Left(5) + sCaseId.right(10).left(5).replace('0','') + sCaseId.right(5); threadIdPart2 = threadIdPart2.substring(0,threadIdPart2.length()-3)+':ref'; String threadId = threadIdPart1 + threadIdPart2; System.debug('Thread Id^^'+threadId);
Output:
See also:
- Multiple Checkbox Checked Value in Lightning Component
- Send Email Lightning Component
- Delete Lightning Component in Salesforce
Thank you.
2 Comments
I am very ecstatic when I am reading this blog post because it is written in a good manner and the writing topic for the blog is excellent.
ReplyDeleteThanks for sharing valuable information. Also get to know about Salesforce Lightning Consultant
Thanks a lot nathan.
DeletePost a Comment