0

I am trying to trigger send an email using TriggeredSendDefinition. Every time I am receiving an email from the DEFAULT account (Business unit email id).

I tried to give from address in TriggeredSendDefinition ,Owner and SenderProfile. But no luck.

How do I solve this issue? How do I modify the From Address during mail send?

Here is my code:

    ETClient client = new ETClient();
    Integer myEmailsId = 2648;
    String triggerSendsExternalKey = "MyTriggerSendTest";
    Soap stub = client.getSoapConnection().getSoap();

    TriggeredSendDefinition sendDefinition = new TriggeredSendDefinition();
    sendDefinition.setCustomerKey(triggerSendsExternalKey); // this is that External_Key
    sendDefinition.setPriority("High");
    sendDefinition.setTriggeredSendStatus(TriggeredSendStatusEnum.NEW);
    sendDefinition.setCCEmail("unknown@example.com;unknown@test.com");
    sendDefinition.setBccEmail("unknown@test.com");
    sendDefinition.setFromAddress("noreply@example.com");
    sendDefinition.setFromName("Bonjour <noreply@example.com>");
    sendDefinition.setReplyToAddress("abc@example.com");
    sendDefinition.setReplyToDisplayName("Example");
    sendDefinition.setEmailSubject("SomeTest");
    sendDefinition.setDynamicEmailSubject("This is Test EMAIL !!!");
    Owner owner = new Owner();
    owner.setFromName("FromName"); // At run time you change from user and email address
    owner.setFromAddress("example@example.com");

    sendDefinition.setOwner(owner);

    sendDefinition.setTriggeredSendType(TriggeredSendTypeEnum.CONTINUOUS);

    SendClassification sendClassification = new SendClassification();
    SenderProfile senderProfile = new SenderProfile();
    // senderProfile.setAutoReplyTriggeredSend(sendDefinition);
    senderProfile.setFromAddress("noreply@example.com");
    senderProfile.setFromName("Bonjour <noreply@example.com>");
    senderProfile.setReplyToAddress("abc@example.com");
    senderProfile.setReplyToDisplayName("Example");
    sendClassification.setSenderProfile(senderProfile);
    // sendClassification.setId(myEmailsId);
    sendDefinition.setSendClassification(sendClassification);

    Email email = new Email();
    email.setId(myEmailsId);
    email.setHtmlBody("<html><b>THIS IS A TEST</b></html>");
    email.setIsHTMLPaste(true);
    email.setHasDynamicSubjectLine(true);
    email.setSubject("This is Test mail");
    email.setTextBody("Test mail");

    com.exacttarget.fuelsdk.internal.List l1 = new com.exacttarget.fuelsdk.internal.List();
    l1.setId(myEmailsId);
    TriggeredSend triggeredSend = new TriggeredSend();
    triggeredSend.setId(myEmailsId);
    triggeredSend.setOwner(owner);
    ArrayList<String> to = new ArrayList<String>();
    to.add("unknown@example.com");

    sendDefinition.setEmail(email);

    for (String emailTo : to) {
        Subscriber sub = new Subscriber();
        // EMail to be sent
        sub.setEmailAddress(emailTo); // Subscriber to whom email should be
                                        // sent.
        sub.setSubscriberKey(emailTo);// Unique identifier for this email_Id
        sub.setStatus(SubscriberStatus.ACTIVE);
        Attribute att1 = new Attribute();
        att1.setName("First Name");
        att1.setValue("TestUser");
        Attribute att2 = new Attribute();
        att2.setName("EmailAddress");
        att2.setValue(emailTo);

        sub.getAttributes().add(att1);
        sub.getAttributes().add(att2);

        triggeredSend.getSubscribers().add(sub);
        l1.getSubscribers().add(sub);
        sendDefinition.setList(l1);
    }
    triggeredSend.setTriggeredSendDefinition(sendDefinition);
    CreateOptions createOptions = new CreateOptions();
    createOptions.setRequestType(RequestType.SYNCHRONOUS);
    CreateRequest createRequest = new CreateRequest();
    createRequest.setOptions(createOptions);
    // createRequest.getObjects().add(replyMailManagementConfiguration);
    createRequest.getObjects().add(triggeredSend);
    CreateResponse createResponse = stub.create(createRequest);

    System.out.println("TriggeredSend :::  "+createResponse);
1

The from address is controlled by the Sender Classification (Profile) specified in the TriggeredSendDefinition. It's possible to make it dynamic as you've suggested.

You'll need SFMC support to enable the ENHANCED SENDER PROFILE business rule (as referenced in this post by a SF staffer).

All you need after that is just to pass the attributes in your API call -- ones that match the names of your Profile Attributes (or variable names, depending on how you want to set those values).

  • Thanks for your answer. I have created Sender Classification and Sender Profiles. After that I have modified the Triggered Sends (Interactions -->Triggered Emails --> Under Messages, Email -->Triggered Sends) by changing the Send Classification with the newly created one. But still I am getting the mail from the DEFAULT profile. – Unknown Sep 18 '16 at 11:24
  • Did you publish the trigger after the changes? – Adam Spriggs Sep 18 '16 at 11:35
  • Ah now I am getting mail from the profile which I have created, after doing Pause + Publish Changes + Start/Restart . I did Pause + Save + Start/Restart before. Thanks for your help. For dynamic sender name and email I need to use AMPscript? – Unknown Sep 18 '16 at 11:48

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.