Code@ Questions have Moved!

In an effort to streamline our efforts, Code@ has moved the Questions and Answers section to the Salesforce StackExchange site, which you can find at the following url: http://salesforce.stackexchange.com/questions/tagged/exacttarget. Please be sure to TAG YOUR QUESTIONS with exacttarget, so our partners know specifically what application your question is pertaining to, and our experts can provide you with a more timely response.

We will discontinue support for this section, and will only be monitoring questions at that location. If your question is currently unanswered, feel free to post that same question on StackExchange to the broader community.

Thank you for your understanding!

Home / question / Trying to send an email using SOAP API send email using list
Ask A Question

Trying to send an email using SOAP API send email using list

0 points
ogbinarheb's picture

_______________REQUEST EmailSendDefinition 

<CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">

         <Options/>

         <Objects xsi:type="ns1:EmailSendDefinition" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">

            <CustomerKey>32101</CustomerKey>

            <Name>testemaildefinitionname01</Name>

            <SendClassification> 

  <CustomerKey>SendClassificationkey</CustomerKey>

               <Name>SendClassificationname</Name>

            </SendClassification>

               <SendDefinitionList>

              <CustomObjectID>0fa8d323-265a-4a66-8f0a-11180bae1326</CustomObjectID>

<List><ID>311790</ID> </List>

               <DataSourceTypeID>List</DataSourceTypeID>

 

            </SendDefinitionList>

<Email><ID>445681</ID></Email>

             

            <IsMultipart>true</IsMultipart>

         </Objects>

      </CreateRequest>

 

_______________RESPONSE EmailSendDefinition 

CreateResponse xmlns="http://exacttarget.com/wsdl/partnerAPI">

         <Results>

            <StatusCode>Error</StatusCode>

            <StatusMessage>Each data extension in a production or test send audience must be sendable.

CustomObjectID: 0fa8d323-265a-4a66-8f0a-11180bae1326

SendDefinitionList::ValidateForSave()</StatusMessage>

            <OrdinalID>0</OrdinalID>

            <ErrorCode>9999999</ErrorCode>

            <NewID>0</NewID>

            <Object xsi:type="EmailSendDefinition">

               <PartnerKey xsi:nil="true"/>

               <ObjectID xsi:nil="true"/>

               <CustomerKey>32101</CustomerKey>

               <Name>testemaildefinitionname01</Name>

               <SendClassification>

                  <PartnerKey xsi:nil="true"/>

                  <ObjectID xsi:nil="true"/>

                  <CustomerKey>SendClassificationkey</CustomerKey>

                  <Name>SendClassificationname</Name>

               </SendClassification>

               <SendDefinitionList>

                  <PartnerKey xsi:nil="true"/>

                  <ObjectID xsi:nil="true"/>

                  <List>

                     <PartnerKey xsi:nil="true"/>

                     <ID>311790</ID>

                     <ObjectID xsi:nil="true"/>

                  </List>

                  <CustomObjectID>0fa8d323-265a-4a66-8f0a-11180bae1326</CustomObjectID>

                  <DataSourceTypeID>List</DataSourceTypeID>

               </SendDefinitionList>

               <Email>

                  <PartnerKey xsi:nil="true"/>

                  <ID>445681</ID>

                  <ObjectID xsi:nil="true"/>

               </Email>

               <EmailSubject>Example Subject</EmailSubject>

               <IsMultipart>true</IsMultipart>

            </Object>

         </Results>

         <RequestID>eaed14b9-73be-4bce-86cd-7320a4cf3e77</RequestID>

         <OverallStatus>Error</OverallStatus>

      </CreateResponse>

 

_______________QUESTION

i'm getting 

 

<StatusCode>Error</StatusCode>

            <StatusMessage>Each data extension in a production or test send audience must be sendable.

CustomObjectID: 0fa8d323-265a-4a66-8f0a-11180bae1326

SendDefinitionList::ValidateForSave()</StatusMessage>

 

but i'm not using data extension (i understand based on previous questions here the solution here is issendable = true but none of the objects I used have that property)

 

Help Me please!

 

here is the process that i've done

1) create email

2) create subscriber

3) create list  (added subscriber)

4) create send classification

5) create send definition (error)

6) perform send email

 

actually I just want to be able to send an email

Product Group: 

Comments

3720 points
jmeketa's picture

To send an email once you do not need to create an EMailSendDefintion. That is for creating a repeatably callable send. You can just do a create request on the Send object and specify the email ID, List ID, and Send Classification ID that way. To answer your error specifically and for creating then performing an emailsenddefition.

The reason it thinks you are associating a data extension instead of a list is because you are passing the information in the way you do for a data extension (CustomObjectID). You need to pass just the ListID (integer). Try removing the CustomObjectID setting and see if that works. You should also set the SendDefinitionListType to SourceList as working sample below shows.

SOAP Envelope

<s:Envelope
    xmlns:s = "http://schemas.xmlsoap.org/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:3abe7f9d-0c21-43d7-bbda-f1b1f8683273</a:MessageID>
        <ActivityId CorrelationId = "7885110c-f70d-4c4b-a2ce-4e06cf31eb67" xmlns = "http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">2e57bcd1-35d2-4631-9a38-4f1cefc19a3d</ActivityId>
        <a:ReplyTo>
            <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
        </a:ReplyTo>
        <a:To s:mustUnderstand = "1">https://webservice.exacttarget.com/Service.asmx</a:To>
        <o:Security s:mustUnderstand = "1" xmlns:o = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <u:Timestamp u:Id = "_0">
                <u:Created>2012-11-26T18:27:21.138Z</u:Created>
                <u:Expires>2012-11-26T18:32:21.138Z</u:Expires>
            </u:Timestamp>
            <o:UsernameToken u:Id = "uuid-d5b56754-c6d3-40b6-8172-b416950c018a-3">
                <o:Username><!--Removed-->
                </o:Username>
                <o:Password><!--Removed-->
                </o:Password>
            </o:UsernameToken>
        </o:Security>
    </s:Header>
    <s:Body xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
        <CreateRequest xmlns = "http://exacttarget.com/wsdl/partnerAPI">
            <Options></Options>
            <Objects xsi:type = "EmailSendDefinition">
                <PartnerKey xsi:nil = "true"></PartnerKey>
                <ObjectID xsi:nil = "true"></ObjectID>
                <CustomerKey>API Academytest</CustomerKey>
                <Name>API AcademyTest</Name>
                <SendClassification>
                    <PartnerKey xsi:nil = "true"></PartnerKey>
                    <ObjectID xsi:nil = "true"></ObjectID>
                    <CustomerKey>10866</CustomerKey>
                </SendClassification>
                <SendDefinitionList>
                    <PartnerKey xsi:nil = "true"></PartnerKey>
                    <ObjectID xsi:nil = "true"></ObjectID>
                    <List>
                        <PartnerKey xsi:nil = "true"></PartnerKey>
                        <ID>1743637</ID>
                        <ObjectID xsi:nil = "true"></ObjectID>
                    </List>
                    <SendDefinitionListType>SourceList</SendDefinitionListType>
                    <DataSourceTypeID>List</DataSourceTypeID>
                </SendDefinitionList>
                <Email>
                    <PartnerKey xsi:nil = "true"></PartnerKey>
                    <ID>3119141</ID>
                    <ObjectID xsi:nil = "true"></ObjectID>
                </Email>
            </Objects>
        </CreateRequest>
    </s:Body>
</s:Envelope>

 

C# Code


        try
        {
            //Create EmailSendDefinition object [Messages > Email > User-Initiated]
            EmailSendDefinition esd = new EmailSendDefinition();
            esd.Name = "Test";//required but you can create your own unique name
            esd.CustomerKey = "test";//required key for send definition, but you can change to your own value if you do not want to use
            
            //Create Email object to refer to pre-create Email
            Email em = new Email();
            em.ID = 3119141;//required //Available in the ET UI [Content > My Emails > Properties]
            em.IDSpecified = true;//required

            //Apply Email object to the EmailSendDefiniton object
            esd.Email = em;//required

            //Create SendClassification
            SendClassification sc = new SendClassification();
            sc.CustomerKey = "10866";//your send classification customerkey may differ

            esd.SendClassification = sc;//required

            //Set Send Definition List for the EmailSendDefinition
            esd.SendDefinitionList = new SendDefinitionList[1];//You can have many SendDefinitonLists of different SendDefinitionListTypes
            esd.SendDefinitionList[0] = new SendDefinitionList();
            esd.SendDefinitionList[0].SendDefinitionListType = SendDefinitionListTypeEnum.SourceList;
            esd.SendDefinitionList[0].SendDefinitionListTypeSpecified = true;
            esd.SendDefinitionList[0].List = new List();
            esd.SendDefinitionList[0].List.ID = 1743637;
            esd.SendDefinitionList[0].List.IDSpecified = true;
            esd.SendDefinitionList[0].DataSourceTypeID = DataSourceTypeEnum.List;//This specifies a List
            esd.SendDefinitionList[0].DataSourceTypeIDSpecified = true;

            try
            {
                string cRequestID = String.Empty;
                string cStatus = String.Empty;

                //Call the Create method on the EmailSendDefinition object
                CreateResult[] cResults = client.Create(new CreateOptions(), new APIObject[] { esd }, out cRequestID, out cStatus);

                //Display Results
                lblMessage.Text += "Overall Status: " + cStatus;
                lblMessage.Text += "<br/>";
                lblMessage.Text += "Number of Results: " + cResults.Length;
                lblMessage.Text += "<br/>";

                //Loop through each object returned and display the StatusMessage
                foreach (CreateResult cr in cResults)
                {
                    lblMessage.Text += "Status Message: " + cr.StatusMessage;
                    lblMessage.Text += "<br/>";
                }
            }
            catch (Exception exCreate)
            {
                //Set Message
                lblMessage.Text += "<br/><br/>CREATE ERROR:<br/>" + exCreate.Message;
            }
        }
        catch (Exception exc)
        {
            //Set Message
            lblMessage.Text += "<br/><br/><h3>ERROR</h3><br/>" + exc.Message;
        }

 

Thanks,

Jason