Skip to main content
added in code that isn't sending emails
Source Link
denvergreene
  • 1.2k
  • 3
  • 20
  • 43

When I refresh a sandbox I have a class that runs to fix some things like email addresses and custom settings. I've also been asked to email the developer the new org ID so that their testing environments can stay connected.

The problem is when I refresh the sandbox, email deliverability defaults to "system email only", and I cannot switch it to "All Emails" until after logging in, which is well after the refreshpostcopy has run. This means I can't email as part of the refreshpostcopy.

Is there a way to set email deliverability to "all emails" in apex? If not is there another way to get the developer that information?

    String sysemail = [SELECT Email FROM User WHERE Email like 'myusername' LIMIT 1].email;
            
    List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    List<String> sendTo = new List<String>();
    sendTo.add('[email protected]');
    mail.setToAddresses(sendTo);
    mail.setSubject('Subject');
    mail.setPlainTextBody('New Sandbox ID is '+context.organizationId());
    mails.add(mail);
    Messaging.sendEmail(mails);

The error I get is System.EmailException: SendEmail failed. First exception on row 0; first error: NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile.: []

When I refresh a sandbox I have a class that runs to fix some things like email addresses and custom settings. I've also been asked to email the developer the new org ID so that their testing environments can stay connected.

The problem is when I refresh the sandbox, email deliverability defaults to "system email only", and I cannot switch it to "All Emails" until after logging in, which is well after the refreshpostcopy has run. This means I can't email as part of the refreshpostcopy.

Is there a way to set email deliverability to "all emails" in apex? If not is there another way to get the developer that information?

When I refresh a sandbox I have a class that runs to fix some things like email addresses and custom settings. I've also been asked to email the developer the new org ID so that their testing environments can stay connected.

The problem is when I refresh the sandbox, email deliverability defaults to "system email only", and I cannot switch it to "All Emails" until after logging in, which is well after the refreshpostcopy has run. This means I can't email as part of the refreshpostcopy.

Is there a way to set email deliverability to "all emails" in apex? If not is there another way to get the developer that information?

    String sysemail = [SELECT Email FROM User WHERE Email like 'myusername' LIMIT 1].email;
            
    List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    List<String> sendTo = new List<String>();
    sendTo.add('[email protected]');
    mail.setToAddresses(sendTo);
    mail.setSubject('Subject');
    mail.setPlainTextBody('New Sandbox ID is '+context.organizationId());
    mails.add(mail);
    Messaging.sendEmail(mails);

The error I get is System.EmailException: SendEmail failed. First exception on row 0; first error: NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile.: []

Clarified the problem regarding order of operations.
Source Link
denvergreene
  • 1.2k
  • 3
  • 20
  • 43

When I refresh a sandbox I have a class that runs to fix some things like email addresses and custom settings. I've also been asked to email the developer the new org ID so that their testing environments can stay connected.

The problem is when I can only send an email once I've switchedrefresh the sandbox, email deliverability defaults to "system email only", and I cannot switch it to "All emails" butEmails" until after logging in, which is well after the refreshpostcopy has run. This means I can't do that beforeemail as part of the sandbox post refresh happensrefreshpostcopy.

Is there a way to set email deliverability to "all emails" in apex? If not is there another way to get the developer that information?

When I refresh a sandbox I have a class that runs to fix some things like email addresses and custom settings. I've also been asked to email the developer the new org ID so that their testing environments can stay connected.

The problem is I can only send an email once I've switched the email deliverability to "All emails" but I can't do that before the sandbox post refresh happens.

Is there a way to set email deliverability in apex? If not is there another way to get the developer that information?

When I refresh a sandbox I have a class that runs to fix some things like email addresses and custom settings. I've also been asked to email the developer the new org ID so that their testing environments can stay connected.

The problem is when I refresh the sandbox, email deliverability defaults to "system email only", and I cannot switch it to "All Emails" until after logging in, which is well after the refreshpostcopy has run. This means I can't email as part of the refreshpostcopy.

Is there a way to set email deliverability to "all emails" in apex? If not is there another way to get the developer that information?

edited tags
Link
sfdc
  • 13.8k
  • 19
  • 136
  • 218
Source Link
denvergreene
  • 1.2k
  • 3
  • 20
  • 43
Loading