5 Replies Latest reply on Jul 26, 2016 11:08 AM by Maheswar Gunampally

    Send Many to One Email Using Custom Objects

    Mihai Bejgu

      Hello everyone,

      I've been really struggling for a while with a pretty difficult task and I really need some clear advice.


         - I need to send out an email, to several Leads that own multiple Accounts.
         - Each Account has it's own unique values and the account ID should be the secondary unique value (After the email address).

      The challenge is to send out 5 (or more emails - depending on how many associated accounts each Lead has) to the same (email address) and each email should contain the Dynamic values that correspond to the Account ID


      For this, I have created a custom Object, that I populated, for testing purposes, with several details that are in the attached .png.

      In the custom object I defined
           - Link value=Email Address

           - Dedupe value = QBR_IdAccount

           - There needs to be several more values as string (but first I need to figure out how to do this right)


      Looking at the "qbrprint.png", how can I send to Mihai Bejgu (only one email address associated), 5 emails individual emails, for each QBR_Id Acount, that will contain it's associated QBR_graphURL?

      I've read a lot of documentation on the Custom Objects, Velocity Email Scripts, but couldn't find exactly what I need.

      I tried defining the attached "Smart List.png", but it didn't work.

      Can you please advise on how to set this up, to work correctly?

      Kind regard,

        • Re: Send Many to One Email Using Custom Objects
          Courtney Grimes

          Hi Mihai,


          Your problem is inherent to the way Marketo works on two fronts: the first being that you cannot loop a person through a flow step multiple times with different selectors, and the other being that if you're trying to reference multiple objects but only want one object in an email, Marketo's simply going to pick the oldest custom object to pull data from.


          Now, there's two solutions to that: the simpler one would be to simply write a Velocity script that checks the lead's email address against the custom object's Email_Address field and outputs all data into one email. I'd also think that for UX purposes your leads would prefer that route.


          However, if that's not an option, you're going to need additional fields on your object to count the unique number of objects per email address and then run campaigns that select objects with that count constraint (so you'd have a smart campaign for people who have "first custom object," "second custom object," "third custom object," and so forth. In fact, you could even hybridize the approach so, say, if someone has three or less objects to send individual emails and if they have more than three to concatenate them all into one email.

          2 of 2 people found this helpful
            • Re: Send Many to One Email Using Custom Objects
              Justin Norris

              I agree with Courtney that you'd save a lot of headache by using a script to output all the QBR data from your custom object into a single email. This is consistent with how custom objects seem designed to be used.


              Courtney's work-around for multiple object records and multiple emails would work but is hard to scale if there are an indeterminate number of possible QBR records per email address.

            • Re: Send Many to One Email Using Custom Objects

              Hi Mihai,


              How are these custom objects being created in Marketo?

              Are these custom object records are 'already populated' in Marketo for all the leads that you need to send emails to?


              Right now you are just testing for your record but for real workflow, these custom object records are 'yet to be populated' in Marketo from some external system?


              If they are yet to be added into Marketo, you can create a smart campaign that listens to 'Record is added to that custom object' event and simply print 'Triggered record" in the email using Velocity Script. Like $TriggerObject.QBR_IdAccount


              For example,



              <strong>Your order information:</strong>

              ##pull information from the Triggering Order and format it in a list


              <li>Product Ordered: $!{TriggerObject.ProductName}</li>

              <li>Product Quantity: $!{TriggerObject.Quanitity}</li>

              <li>Shipping Address: $!{TriggerObject.ShippingAddress}</li>

              <li>Billing Address: $!{TriggerObject.BillingAddress}</li>

              <li>Order Total: $!{TriggerObject.Amount}</li>


              <p><a href="$!{TriggerObject.OrderURL}">View Your Order Online</a></p>




              That way, you can send 1 email to the lead, when the new QBR record is created, with the email containing 'only' that QBR record's information. If a lead has 5 or 15 QBR records, each of them will be added one by one (from the external system) and will get a different email each containing only that QBR record's information.


              Does this help? This is how we did similar work a year back. Please feel free to reach out if you have any questions.


              This will not work if the QBR data is already in Marketo though.


              Rajesh Talele

              408 306 8767


              1 of 1 people found this helpful