I am trying to create and send an email using the C# FuelSDK. I can successfully create the email. It shows up in the list of emails. I can also successfully use the API to send the email to an existing List.
However when I look at tracking, it says 'Error' and says it was sent to 0 recipients.
The folks at MC could only share this error message detail and they did not know either.
"An error occurred when attempting to resolve a function call. See inner exception for detail. Function Call: iif(empty(__AdditionalEmailAttribute3),MemberID,__AdditionalEmailAttribute3)"
string clientId = System.Configuration.ConfigurationManager.AppSettings["clientId"];
string clientSecret = System.Configuration.ConfigurationManager.AppSettings["clientSecret"];
int maxEmailsToBeCreated = int.Parse(System.Configuration.ConfigurationManager.AppSettings["maxEmailsToBeCreated"]);
NameValueCollection parameters = new NameValueCollection();
parameters.Add("clientId", clientId);
parameters.Add("clientSecret", clientSecret);
ET_Client myclient = new ET_Client(parameters);
DBStuff context;
using(context = new DBStuff()) {
var a = from b in context.StuffTable.OrderByDescending(m => m.CreatedDate).Take(maxEmailsToBeCreated) select b;
var reports = a.ToList();
foreach(var report in reports) {
ET_Email email = new ET_Email();
email.AuthStub = myclient;
var body = MailBodyBuilder.RenderBody(report);
email.Name = report.Title;
email.CustomerKey = report.Id.ToString();
email.Subject = report.Title;
email.HTMLBody = body;
PostReturn response = email.Post();
Console.WriteLine("Post Status: " + response.Status.ToString());
ET_Send send = new ET_Send();
send.AuthStub = myclient;
send.Email = email;
send.FromAddress = "***@***.com";
send.CreatedDate = DateTime.Now;
send.CreatedDateSpecified = true;
send.CustomerKey = Guid.NewGuid().ToString();
send.FromName = "Some Guy";
send.Subject = report.Title;
send.IsMultipart = true;
send.IsMultipartSpecified = true;
ET_List list = new ET_List();
list.ID = 123; // The ID of an existing list
list.IDSpecified = true;
send.List = new List[1];
send.List[0] = list;
FuelSDK.PostReturn postReturn = send.Post();
Console.WriteLine("Send Status: " + postReturn.Status.ToString());
}
}