I'm having trouble finding an example or instructions on how to make triggered sends with dynamic attributes using Fuel Java SDK or the REST API.

Example: for this template below, I'd like to be able to send a transactional email whilst overriding the variables with correct values, which will be specific for each send.

Hello %%First_Name%%,

User %%Other_User_Name%% has viewed your document %%Document_Title%% on %%View_Date%%.

The example in


and in


doesn't specify how to do this via the Fuel Java SDK (or through the rest API).k

Could someone confirm whether it's possible and how to do this in ET?

Thanks -greg

1 Answer 1


Yes it is possible.

Once the triggered send is defined you can use the body of the request to send the attributes.

Here is some pseudo code examples of it:

Object Definitions

*   Message Send Classes

public class messageSendBody{
    public To To {get;set;}

    public messageSendBody(Id oId){
        Opportunity o = [Select 
                          ....Your Fields Here........
                            From Opportunity Where Id = :oId];

        SubscriberAttributes attr = New SubscriberAttributes();
        attr.Offer = o.Offer__c;
        attr.offerID = o.Offer_ID__c;
        attr.billing_First_Name = o.FIELDAPINAME;
        attr.billing_Last_Name = o.FIELDAPINAME;
        attr.billing_Email = o.FIELDAPINAME;
        attr.Customer_Loyalty_Number = o.FIELDAPINAME;

        To = New To(attr.billing_email,attr);

public class messageStatus{
    public dateTime deliveryTime {get;set;}
    public string id {get;set;}
    public string messageId {get;set;}
    public string status {get;set;}
    public To to {get;set;}
    public messageErrors[] messageErrors {get;set;}

public class To{
    public string Address {get;set;}
    public string SubscriberKey {get;set;}
    public ContactAttributes ContactAttributes {get;set;}

    public To(String a, SubscriberAttributes sa){
        Address = a;
        SubscriberKey = a;
        ContactAttributes = New ContactAttributes(sa);

public class ContactAttributes{
    public SubscriberAttributes SubscriberAttributes {get;set;}

    public ContactAttributes(SubscriberAttributes s){
        SubscriberAttributes = s;

public class SubscriberAttributes{
    public String Offer {get;set;}
    public String Billing_First_Name {get;set;}
    public String Billing_Last_Name {get;set;}
    public String Billing_Email {get;set;}
    public String Billing_Company {get;set;}
    public String Billing_Address {get;set;}
    public String Billing_Address_Line_2 {get;set;}
    public String Billing_Zip_Postal {get;set;}
    public String Customer_Loyalty_Number {get;set;}
    public String Purchased_Product {get;set;}
    public String Price_Paid {get;set;}
    public String New_Expiration_Date {get;set;}
    public String OfferID {get;set;}
    public String Key {get;set;}


To send you do the regular authentication stuff and do something line this in the code:

HTTPRequest req = New HTTPRequest();
        new messageSendBody(oppId)

How you structure your classes and methods is up to your processes. The important part is the To class and the SubscriberAttributes

  • Thanks for the example. A clarification: In the SubscriberAttributes example, you set the values to the object you've extracted from the SFDC DB using SOQL, if I understood correctly. Can those values be constants I provide myself from data external to Salesforce? In my example, these are transactional emails that happen in our product (website) and some of the data isn't necessarily synced with Salesforce
    – gregsilin
    Dec 29, 2015 at 20:44
  • You can populate the value however you need to populate them and / or change the structure of the class as needed. In my example I am using data from the opportunity in one system to trigger the send in another (that does not have the data from the calling system)
    – Eric
    Dec 29, 2015 at 21:11
  • Thanks! One more question: this doesn't seem to take advantage of the Fuel Java SDK, is this functionality supported in the SDK?
    – gregsilin
    Dec 29, 2015 at 21:15
  • It uses the Fuel REST API. and the code I presented is apex code within salesforce that was written. The same functionality should exist in the SDK if you adapt the above to it as the SDK is a wrapper around the API. Since you said "or" Rest API I though it might be of help
    – Eric
    Dec 29, 2015 at 21:18
  • Your answer is extremely helpful. Just trying to squeeze the most out of your response :)
    – gregsilin
    Dec 29, 2015 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .