0

I'm trying to create an EmailSendDefinition which makes use of a filter, but am getting the following exception: Exception occurred during [CreateEmailSendDefinition] ErrorID = 1719440099.

I based my code on the example located at https://code.exacttarget.com/apis-sdks/soap-api/starting-an-email-send-definition.html (under the section title "Sample .NET Start Code Using a Filter Definition").

My code is as follows:

    private EmailSendDefinition CreateEmailSendDefinition(int businessUnitId, string online, int emailId, string newsletterName, DateTime sendDateTime)
{
    var filter = GetFilterDefinition("WaterOnline Filter", businessUnitId);

    var sendClassification = GetSendClassification(businessUnitId);
    if (sendClassification == null)
        throw new ApplicationException("Couldn't find default commercial send classification.");

    EmailSendDefinition definition = new EmailSendDefinition();

    definition.Name = newsletterName + " Send Definition";
    definition.CustomerKey = GetEmailSendDefinitionCustomerKey(emailId);

    Email email = new Email();
    email.ID = emailId;
    email.IDSpecified = true;

    definition.Email = email;
    definition.SendClassification = sendClassification;

    definition.SendDefinitionList = new SendDefinitionList[1];
    definition.SendDefinitionList[0] = new SendDefinitionList();

    definition.SendDefinitionList[0].SendDefinitionListType = SendDefinitionListTypeEnum.SourceList;
    definition.SendDefinitionList[0].SendDefinitionListTypeSpecified = true;
    definition.SendDefinitionList[0].FilterDefinition = filter;
    definition.SendDefinitionList[0].DataSourceTypeID = DataSourceTypeEnum.FilterDefinition;
    definition.SendDefinitionList[0].DataSourceTypeIDSpecified = true;

    ClientID clientID = new ClientID();
    clientID.ID = businessUnitId;
    clientID.IDSpecified = true;
    definition.Client = clientID;

    definition.IsMultipart = true;
    definition.IsMultipartSpecified = true;
    APIObject[] createObjects = { definition };
    String requestId = null;
    String overallStatus = null;
    CreateResult[] results =
        _client.soapclient.Create(new CreateOptions(), createObjects, out requestId, out overallStatus);

    if (results == null || !results.Any())
        throw new ApplicationException("No results from call to create EmailSendDefinition.");
    else if (results.Any(x => x.ErrorCodeSpecified))
        throw new ApplicationException($"Error attempting to create EmailSendDefinition: {results.FirstOrDefault(y => y.ErrorCodeSpecified).StatusMessage}");

    return definition;
}

The FilterDefinition object I'm using (the variable named filter) is a valid FilterDefinition retrieved via the API. It has the following properties set: Name, Description, ObjectID, CustomerKey.

What am I doing wrong here?

Thanks!

2 Answers 2

1

This is how I eventually got it to work:

    private EmailSendDefinition CreateEmailSendDefinitionForSubscribers(int businessUnitId, int emailId, string newsletterName, string filterName)
    {
        string dataExtensionId = GetDataExtensionID($"Profile - All Subscribers", businessUnitId);
        var filter = GetFilterDefinition(filterName, businessUnitId);

        var sendClassification = GetSendClassification(businessUnitId);
        if (sendClassification == null)
            throw new ApplicationException("Couldn't find default commercial send classification.");

        EmailSendDefinition definition = new EmailSendDefinition();

        definition.Name = newsletterName + " Send Definition For Subscribers";
        definition.CustomerKey = GetEmailSendDefinitionForSubscribersCustomerKey(emailId);

        Email email = new Email();
        email.ID = emailId;
        email.IDSpecified = true;

        definition.Email = email;
        definition.SendClassification = sendClassification;

        definition.SendDefinitionList = new SendDefinitionList[2];

        definition.SendDefinitionList[0] = new SendDefinitionList();
        definition.SendDefinitionList[0].SendDefinitionListType = SendDefinitionListTypeEnum.SourceList;
        definition.SendDefinitionList[0].SendDefinitionListTypeSpecified = true;
        definition.SendDefinitionList[0].FilterDefinition = filter;
        definition.SendDefinitionList[0].DataSourceTypeID = DataSourceTypeEnum.FilterDefinition;
        definition.SendDefinitionList[0].DataSourceTypeIDSpecified = true;

        definition.SendDefinitionList[1] = new SendDefinitionList();
        definition.SendDefinitionList[1].SendDefinitionListType = SendDefinitionListTypeEnum.ExclusionList;
        definition.SendDefinitionList[1].SendDefinitionListTypeSpecified = true;
        definition.SendDefinitionList[1].DataSourceTypeID = DataSourceTypeEnum.CustomObject;
        definition.SendDefinitionList[1].DataSourceTypeIDSpecified = true;
        definition.SendDefinitionList[1].CustomObjectID = dataExtensionId;

        return PersistEmailSendDefinition(definition, businessUnitId);
    }
0

Try assign clientID object to SendDefinitionList[0]:

definition.SendDefinitionList[0].Client = clientID;

You must log in to answer this question.

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