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
Mike FMike F 

Is there a way to retrieve Email to Case routing addresses from Apex?

I would like to be able to retrieve all of the email addresses enumerated in Email to Case settings through Apex.
Is this possible?
karthikeyan perumalkarthikeyan perumal
Hello, 

Yes its possible to get the Routing address from Email-to-case Setting, but you can't get that routing full address directly.

you have to do some tricky part. 

Like Query the fields  from the Object called  "EmailServicesAddress"   

"SELECT EmailDomainName,IsActive,LocalPart FROM EmailServicesAddress"   it will display  EmailDomainName, LocalPart  these to things contain your routing address part.

after Query those part you have to form a string like below

LocalPart @ EmailDomainName--- This is your routing address. which you configured in that Email to case settings. 

Hope this will gelp you.
Mark Best ANSWER if its works for you. 

Thanks
karthik
 
Mike FMike F
Thanks karthik, that defintely takes me alot further. What's missing for me is the actual email address that is mapped to the service address. I need to be able to inspect an incoming EmailMessage and detect which routing address the ToAddress maps to. Basically it's the table you see when you manage Email-To-Case settings in an org. Is there a way to look that up as well?
karthikeyan perumalkarthikeyan perumal
Hello, 
EmailServicesAddress---AuthorizedSenders
EmailMessage--Incoming,ToAddress 

For this you need compare 2 objects in compare "AuthorizedSenders " in EmailServicesAddress and To address in EmailMessage and get the "Incoming "is true or false. bsaaed on that you do your thing. 

Thanks
karthik