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!