Skip to main content
added 63 characters in body
Source Link
sfdc
  • 13.8k
  • 19
  • 137
  • 219

When you create/refresh sandbox, Email Deliverability is setdefault to System Email Only. YouSystem Email Only allows us to send emails to users or reset passwords.You can run below class, when you create/refresh sandbox. enter image description here

BelowWhen you run below class then it will update all System Admin's user's email address and that will eventually send email to user.

global class SandboxPostRefresh_AC implements SandboxPostCopy { global void runApexClass(SandboxContext context) { System.debug(context.organizationId()); System.debug(context.sandboxId()); System.debug(context.sandboxName()); run(); } global static void run() { //List of all emails from the User object List<User> userEmailList = [select Email from User where profile.name = ‘System Administrator’]; for(User uc : userEmailList) { uc.Email = uc.Email.replace('=','@'); //to remove appended domain String addedPhrase = '@example.com'; uc.Email = uc.Email.remove(addedPhrase); userEmailList.add(uc); } if(userEmailList.size() > 0) { Update userEmailList; } } } 

When you create/refresh sandbox, Email Deliverability is set to System Only. You can run below class, when you create/refresh sandbox. enter image description here

Below class will update all System Admin's user's email address and that will eventually send email to user.

global class SandboxPostRefresh_AC implements SandboxPostCopy { global void runApexClass(SandboxContext context) { System.debug(context.organizationId()); System.debug(context.sandboxId()); System.debug(context.sandboxName()); run(); } global static void run() { //List of all emails from the User object List<User> userEmailList = [select Email from User where profile.name = ‘System Administrator’]; for(User uc : userEmailList) { uc.Email = uc.Email.replace('=','@'); //to remove appended domain String addedPhrase = '@example.com'; uc.Email = uc.Email.remove(addedPhrase); userEmailList.add(uc); } if(userEmailList.size() > 0) { Update userEmailList; } } } 

When you create/refresh sandbox, Email Deliverability default to System Email Only. System Email Only allows us to send emails to users or reset passwords.You can run below class, when you create/refresh sandbox. enter image description here

When you run below class then it will update all System Admin's user's email address and that will eventually send email to user.

global class SandboxPostRefresh_AC implements SandboxPostCopy { global void runApexClass(SandboxContext context) { System.debug(context.organizationId()); System.debug(context.sandboxId()); System.debug(context.sandboxName()); run(); } global static void run() { //List of all emails from the User object List<User> userEmailList = [select Email from User where profile.name = ‘System Administrator’]; for(User uc : userEmailList) { uc.Email = uc.Email.replace('=','@'); //to remove appended domain String addedPhrase = '@example.com'; uc.Email = uc.Email.remove(addedPhrase); userEmailList.add(uc); } if(userEmailList.size() > 0) { Update userEmailList; } } } 
Source Link
sfdc
  • 13.8k
  • 19
  • 137
  • 219

When you create/refresh sandbox, Email Deliverability is set to System Only. You can run below class, when you create/refresh sandbox. enter image description here

Below class will update all System Admin's user's email address and that will eventually send email to user.

global class SandboxPostRefresh_AC implements SandboxPostCopy { global void runApexClass(SandboxContext context) { System.debug(context.organizationId()); System.debug(context.sandboxId()); System.debug(context.sandboxName()); run(); } global static void run() { //List of all emails from the User object List<User> userEmailList = [select Email from User where profile.name = ‘System Administrator’]; for(User uc : userEmailList) { uc.Email = uc.Email.replace('=','@'); //to remove appended domain String addedPhrase = '@example.com'; uc.Email = uc.Email.remove(addedPhrase); userEmailList.add(uc); } if(userEmailList.size() > 0) { Update userEmailList; } } }