2

I'm currently showing the user's email configuration in my application. However none of this matters if my organization has disabled emails. i have to know if that is true before showing the user his configuration options. I tried looking up the Organization Object but it doesn't seem to have that field. Any help would be much appreciated.

2
  • 2
    The EmailAdministrationSettings object in the Metadata API should be a good starting point. The docs say it "[r]epresents an organization’s email administration settings, including email deliverability,..." but not seeing a field immediately that seems to correspond to the "Access level" dropdown in Setup > Email > Deliverability. May 21, 2020 at 18:20
  • @Bow-chicawow-ers exactly. I've looked into that and i seem to find the equivalent fields inside certain objects but i can't seem to find the field that references that exact field enabling email notifications organization wide.
    – JPG
    May 21, 2020 at 18:35

2 Answers 2

1

I tried the same long back ago, I couldn't find a solution for this. So i went with a solution of adding try/catch blocks, and checking in catch if exception contains so and so, i'm letting the user with a custom message. Though its not a viable solution, but i don't see anything other than this

1
  • I too am struggling with this. Thanks for your answer mate., will take this into account.
    – JPG
    May 21, 2020 at 19:35
0

One alternative way is to retrieve the page content of Email Deliverability using PageReference.getContent() and parse it using regular expression.

For example:

PageReference pr = new PageReference('/email-admin/editOrgEmailSettings.apexp');
String htmlBody = pr.getContent().toString().replace('\n','');
Matcher pm = Pattern.compile('sendEmailAccessControlSelect.+?>\\s*<option.+?"selected">(.+?)</option>').matcher(htmlBody);
String accessLevel;
if (pm.find() && pm.groupCount() > 0) {
    accessLevel= pm.group(1);
}

This would work as long as the page content is unchanged.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .