0

Using the SOAP API Request for Performing a Test Send on a EmailSendDefinition (User-Initated Send), I am unable to get the test send to have the same desired default [Test Send]: prefix that I get when manually performing test sends directly from the User-Initiated Send wizard within Email Studio within the SFMC application. I would think there should be a way to specify this using a property such as . Specifying a test email address seems straightforward . Ofcourse one can use specify a custom subject when creating a EmailSendDefiniton with however that's not what I'm attempting to do. I'm happy with how the default subject is defined in the email which the Email ID maps to it when creating the ESD. I'm looking to alter the Subject Prefix which is a visible parameter that can be adjusted from inside manually sending of a User-Initiated Send.

I have read through the documentation links below and find no hint of how to specify the Subject Prefix.

Can anyone please provide a clue? I would like to also provide my xml soap requests for the EmailSendDefinition for your review. Note: The curly braces are placeholders for values I supply.

SFMC Documentation of Email Send Definition
Creating Performing and Deleting Email Send Definition
Performing Email Send Definition Test Send

Creating a EmailSendDefinition (User-Initated Send)

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Header>
        <fueloauth>{{accessToken}}</fueloauth>
    </Header>
    <Body>
        <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Options/>
            <Objects xsi:type="EmailSendDefinition">
                <PartnerKey xsi:nil="true"/>
                <ModifiedDate xsi:nil="true"/>
                <ObjectID xsi:nil="true"/>
                <Name>{{myemailsenddefinition}}</Name>
                <CustomerKey>{{myemailsenddefinition}}</CustomerKey>
                <Description>Testing new email</Description>
                <SuppressTracking>1</SuppressTracking>
                <CategoryID>205147</CategoryID>
                <SenderProfile>
                  <CustomerKey>920</CustomerKey>
               </SenderProfile>
                <SendClassification>
                   <PartnerKey xsi:nil="true"/>
                   <CustomerKey>712</CustomerKey>
                   <ObjectID xsi:nil="true"/>
                </SendClassification>
                    <SendDefinitionList>
                    <SendDefinitionListType>SourceList</SendDefinitionListType>
                    <CustomerKey>{{mysampledataextension}}</CustomerKey>
                    <DataSourceTypeID>CustomObject</DataSourceTypeID>
                </SendDefinitionList>
                <SendDefinitionList>
                    <SendDefinitionListType>SourceList</SendDefinitionListType>
                    <CustomerKey>{{mysampledataextension}}</CustomerKey>
                    <DataSourceTypeID>CustomObject</DataSourceTypeID>
                    <IsTestObject>true</IsTestObject>
                </SendDefinitionList>
                 <Email>
                    <PartnerKey xsi:nil="true"/>
                    <ModifiedDate xsi:nil="true"/>
                    <ID>510623</ID>
                    <ObjectID xsi:nil="true"/>
                </Email>
            </Objects>
        </CreateRequest>
    </Body>
</Envelope>

Performing a test send for EmailSendDefinition (User-Initated Send)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <fueloauth>{{accessToken}}</fueloauth>
    </soapenv:Header>
    <soapenv:Body>
        <PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Action>test</Action>
            <Definitions>
                <Definition xsi:type="EmailSendDefinition">
                    <CustomerKey>{{myemailsenddefinition}}</CustomerKey>
                    <TestEmailAddr>{{myemailaddress}}</TestEmailAddr>
                </Definition>
            </Definitions>
            <SendClassification>
                <SenderProfile>
                    <CustomerKey>937</CustomerKey>
                </SenderProfile>
            </SendClassification>
        </PerformRequestMsg>
    </soapenv:Body>
</soapenv:Envelope>

3 Answers 3

1

So the EmailSendDefinition test via SOAP Perform method does not really offer this as an option, BUT if you feel comfortable with utilizing undocumented REST endpoints, there is one that you can use for this and it offers the option of a subjectPrefix.

This API endpoint is actually utilized in platform for sending preview/tests, so I would be fairly confident it is stable.

Below is a quick sample on creating this API call:

POST /guide/v1/emails/preview/send 
Host: {{mySubDomain}}.rest.marketingcloudapis.com
Authorization: Bearer {{authToken}}
Content-Type: application/json

{
  "dataSource": {
    "contact": "id:{{contactID}}",
    "id": "1103",
    "type": "List"
  },
  "emailID": {{emailID}},
  "isMultipart": true,
  "options": {
    "EnableETURLs": "true"
  },
  "recipients": [
    "[email protected]"
  ],
  "sendManagement": {
    "deliveryProfileID": "XXXXX-XXXX-XXXXXX",
    "sendClassificationID": "XXXXX-XXXX-XXXXXX",
    "senderProfileID": "XXXXX-XXXX-XXXXXX"
  },
  "subjectPrefix": "[Test_via_API]:",
  "suppressTracking": true,
  "trackLinks": false
}

The main things of note that you will require are:

  1. ContactID
  2. EmailID
  3. DeliveryProfile ID
  4. SendClassification ID
  5. SenderProfile ID

The rest is fairly easy to figure out or fill in to execute the call.

9
  • Thanks for the tip. I would like very much to be able to use REST endpoint but I don't want to use ContactID if it involves Contact Builder. I'll have to map multiple temporary test data extensions within Contact Builder in order to retrieve their ContactID? Each of the EmailSendDefinitions were created temporarily via SOAP API just for seamless rapid testing of email test sends across variable to render future email content updates to active trigger sends. Is there a way to utilize this instead using CustomerKey within DataSource to reference the target EmailSendDefinition and Data Extension. Commented Jan 9, 2020 at 16:45
  • you can also use the contactkey (same as SubscriberKey for Email Studio) via "contact": "key:{{mySubKey}}", if you do not have the contactID easily acessable. Commented Jan 9, 2020 at 17:51
  • or for using Data Extensions, you can use: "dataSource": { "id": "76c5e3f5-a075-e911-a2da-1402ec94baa1", "row": "1", "type": "DataExtension" } Where ID is the Data Extension ID and row is the row number you want to use inside the DE. Commented Jan 9, 2020 at 17:57
  • My data extensions contains 15 records and by bulk test sending I want to use all rows in it which each have a different Brands when render different based on the Brand Name field such as link urls, images, etc. I tried this below and got an 500 internal server error. I checked the endpoint and it matches the Post request with headers. I put the numeric ExternalKey values for default deliveryProfileID, sendClassificationID, senderProfileID. For my test data extensions I use the same value for EXTERNAL KEY as I do for the name for each data extension and I use underscores instead of spaces. Commented Jan 9, 2020 at 19:44
  • Here is my body: {"dataSource": {"id": "UPDATED_ss_0001_OrderConfirmation","type": "DataExtension"},"emailID": 510623,"isMultipart": true,"options": {"EnableETURLs": "true"},"recipients": ["[email protected]"],"sendManagement": {"deliveryProfileID": "394","sendClassificationID": "712","senderProfileID": "937"},"subjectPrefix": "[Test_via_API]:","suppressTracking": true,"trackLinks": false} I suspect something is missing. Commented Jan 9, 2020 at 19:46
0

If your requirement is to update the subject line via SOAP API, then here you go.

Update SL OR/and Body of your HTML email https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/updating_the_subject_and_body_of_an_email_message.htm

I tested the below code works for me. Note: All SOAP API works only for Classic content emails ONLY.

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <s:Header>
      <a:Action s:mustUnderstand="1">Create</a:Action>
      <a:MessageID>urn:uuid:7e0cca04-57bd-4481-864c-6ea8039d2ea0</a:MessageID>
      <a:ReplyTo>
         <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
      </a:ReplyTo>
      <a:To s:mustUnderstand="1">{{soapEndPoint}}</a:To>
      <fueloauth>{{accessToken}}</fueloauth>
   </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">

         <Options/>
         <Objects xsi:type="ns1:Email" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
            <ID>158769</ID>           
            <Subject>New SL updated via SOAP</Subject>
            <HTMLBody><![CDATA[<html><body><table><tr><td>UPDATED BODY CONTENT</td></tr></table></br><a href="http://www.example.com">UPDATED BODY LINK<a/></br>2ADDITIONAL UPDATED BODY CONTENT</body></html>]]></HTMLBody>
         </Objects>
      </UpdateRequest>
   </s:Body>
</s:Envelope>

Note: If you wish to update only SL then you MUST place at least empty data for body as below.

<Subject>New SL updated via SOAP</Subject>
<HTMLBody></HTMLBody>
1
  • Thanks for the info but I am using emails within Content Builder, not Classic Content emails. Commented Jan 9, 2020 at 16:46
0

I spent some time frustrated with this exact thing a while back, and never figured it out. I did figure out how to update the subject line of an email send definition to display a prefix if it was a test send, which functions similar to what you are asking. I ended up coding to add it and remove it for a series of data proofs on a monthly recurring project because I use a series of if then checks on our subject lines to flag emails as test in an offline database.

    private static void sendDataProof(EmailSendDefinition esd)
    {

        esd.TestEmailAddr = ConfigurationManager.AppSettings["DataProofRecipient"];

        string currentSubject = getEmailSubjectLine(client, esd);

        string updatestatus;
        if (!(currentSubject.Contains("_IsTestSend == true")))
        {

            string testSubjectPrefix = @"%%[if _IsTestSend == true then]%%%%= concat('(Data Proof: ',_DataSourceName ,'-', emailaddr,')')=%%%%[ endif ]%%" + currentSubject;

            esd.EmailSubject = testSubjectPrefix;

            updatestatus = updateEmailSendDefinition(client, esd);

        }




        try
        {
            //Perform the ESD
            string pStatus = String.Empty;
            string pMessage = String.Empty;
            string pRequestID = String.Empty;

            PerformResult[] pResults = client.Perform(new PerformOptions(), "test", new InteractionBaseObject[] { esd }, out pStatus, out pMessage, out pRequestID);

            foreach (PerformResult pr in pResults)
            {
                Console.WriteLine("Send performed: " + pr.StatusMessage);
                //Console.ReadLine();
            }

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.ReadLine();
        }

        esd.EmailSubject = currentSubject;
        updateEmailSendDefinition(client, esd);
    }

You must log in to answer this question.

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