Send email where to address is email field in related model?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
  • (Edited)
Model A is parent of Model B and Model C.

Model C has a lookup to another object, which includes an email field. Let's call this Model_C_Email_Lookup__r.Email__c.

When a record is created in Model B, I want to automatically send an email with data from Models A and B, to all the rows in Model C, where the Model_C_Email_Lookup__r.Email__c is the TO field.

I tried workflows and lightning processes, but they both require me to create an SFDC "Email Alert" on the same object that the process/workflow runs on. And from that object (Object B), there's no way for me to access (in the SFDC email alert) the Email Field in the related model, at least not that I can tell.

I don't want the user to have to do anything... this should happen automatically.

Is this impossible? Does this require a foray into apex triggers? Can I set up the standard email URL hack to send automatically? Is there some kind of external email solution I can plug into?

Thanks for the pointers!
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
We've not had much luck with triggering the salesforce native email tools.  This may be a case where you need to go with an external email tool like Marketo.  

You basically need to create a model for object C that gets queried whenever a new row in Model B is created.  (Model Action probably)
Then the rows in Model C need to get passed into the external email generation tool 

Here is  a post Zach wrote about mass email using Marketo.   https://community.skuidify.com/skuid/topics/how_to_add_marketo_send_email_mass_action_to_a_skuid_tab...
Photo of Jack Sanford

Jack Sanford, Champion

  • 8,322 Points 5k badge 2x thumb
Matt - you've probably figured something out by now, but we're doing what you're asking by using Conga Composer and Conga Workflow. If you can get your process to work by pushing a Conga button using background mode, which you could do with a Conga Query to lookup the related model, then you can use that button code to create a Conga Workflow formula field, then you can use the standard SF Workflow Rules to trigger when your Conga Workflow happens. 

For example, we have a DocuSign email auto sent with every new opportunity, to a Contact on an Account related to an Opportunity via a custom join object. 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Thanks, Jack. We're actually using MailGun's REST API to send emails. It's a little clunky, but free!