3

I have a number of Email Notifications that are sent to non-users. Sometimes they are contact emails and others it's straight up email address like "MyPoor_NonSalesforce_Coworker@Mywork.com"

When I refresh a sandbox, User Emails change to @MyWork.com.SandboxName It doesn't look like Contact Email Addresses or any other non-user addresses keep their name.

So if I accidentally do something to a record that triggers and email or a trigger I could be suddenly emailing Sandbox data to a contact or to that other email address without intended to.

Anyone got suggestions on how to handle this? I used to just keep a manual list of my Email notifications and disable them. But as we grow this is taking more and more time. Plus, I'm not the only Admin so I may have to manually review (yuck).

Thoughts?

1

Easiest option might be to just update all the contacts to have fake addresses using data loader, or if the number of contacts would be within governor limits you could run a small script in the execute anonymous section of the developer console:

list<Contact> toUpdate = new list<Contact>();

for(Contact c : [Select Id, Email from Contact])
{
  c.Email += '.fake';
  toUpdate.add(c);

  if(toUpdate.size() == 200)
  {
    update toUpdate;
    toUpdate.clear();
  }
}

if(toUpdate.size() > 0)
{
  update toUpdate;
}

Obivously you could add some more smarts to this if need be, for instance limiting to 20,000 records and only grabbing contacts where the email doens't contain .fake and run it a few times. If you're cutting sandboxes on a regular basis then maybe you could adapt this code to be a class implementing batchable and throw together a quick page to execute the batch when needed, deploy that to your production org and you'll always have it to hand right after creating/refreshing a sandbox!

2
  • How would you handle the emails that are not in the contacts but are stored directly in the email notification? Aug 9 '12 at 2:24
  • 1
    Ah, kinda missed that bit on my first read. I've not come across any way to get access to notifications from code or metadata, you might be out of luck on that front. Might be better to use contacts instead of the other addresses box?
    – Matt Lacey
    Aug 9 '12 at 2:32
1

Could you change the User Permissions for your active user to prevent sending emails?

In the past I've disabled the Send Outbound Messages to similar effect. It might just be a matter of finding the correct permission. Maybe the General User Permissions "Send Email" and/or "Mass Email"?

1
  • 1
    This might work except the Sys Admin would have to also have this disabled so we don't accidentally send out emails when creating test data for our sandbox. The number of profile we'll have to disable and track so we don't impact deploys would also make this a bit arduous workaround. although it should work Sep 26 '12 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.