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
Mario EMario E 

How to set Reply To in an Apex Class and have the replies sent back to the same Case that triggers the Class?

When a Case is closed, it will trigger an Apex class to send an email with the Case details. However, when someone replies to the email, it will go to the Case Owner's work Gmail instead of back to the same Case using the Email-To-Case feature that is already set up and working properly.
I even included the Case Thread Id in the Apex Class and I see it in the email body being sent. 

 

How can I make sure the replied email arrives back in the Case that triggers the Apex Class?

Best Answer chosen by Mario E
Mario EMario E

That Roku suggestion... did not work. I was sooo hopeful!
 
Anyway Looping back here with an answer:

1. Add a formula field on the Object with this formula to create a Case Thread Id:

"ref:_" & LEFT($Organization.Id,5) & SUBSTITUTE(RIGHT($Organization.Id,10), "0", "" )& "._" & LEFT(Id,5) & SUBSTITUTE(Left(RIGHT(Id,10), 5), "0", "") & RIGHT(Id,5) & ":ref"
 

2. Add this in the Apex Class:

// Get Org Wide Email Address and then set it as Reply To address
            OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'younameit@email.com'];
            // Define the email
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            if ( owea.size() > 0 ) {
                email.setOrgWideEmailAddressId(owea.get(0).Id);
            }

 

All Answers

Jessica FrazierJessica Frazier
The most important step while connecting the Roku account and the Roku device is to provide the Roku activation code. You can get the Roku activation code after entering into the Roku account. This code will appear on the Roku TV screen. All that needs to be done is to enter the code in roku.com/link and click the Submit button. And hence the activation process will start 
 
Mario EMario E

That Roku suggestion... did not work. I was sooo hopeful!
 
Anyway Looping back here with an answer:

1. Add a formula field on the Object with this formula to create a Case Thread Id:

"ref:_" & LEFT($Organization.Id,5) & SUBSTITUTE(RIGHT($Organization.Id,10), "0", "" )& "._" & LEFT(Id,5) & SUBSTITUTE(Left(RIGHT(Id,10), 5), "0", "") & RIGHT(Id,5) & ":ref"
 

2. Add this in the Apex Class:

// Get Org Wide Email Address and then set it as Reply To address
            OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'younameit@email.com'];
            // Define the email
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            if ( owea.size() > 0 ) {
                email.setOrgWideEmailAddressId(owea.get(0).Id);
            }

 
This was selected as the best answer
Kates WorthKates Worth

Roku Device activation

  • Find the HDMI port to connect the  device to the TV
  • Select the settings to activate the Network
  • If  the connection is active, link your device to the Roku account
  • Find the code and  then provide the code navigating to the page, Roku,com/link (http://www.rokuactivationcode.xyz)
  • If you come across issues and errors, use the available tips and tricks to resolve it
For further details contact our customer care support number +1-855-748-7900