Okay - why do I want to do this...
My SubscriberKey is my systems ContactID. My contacts can have multiple emails. The SentEvent identifies the Send and the Subscriber Key which I can retrieve successfully. However, I need to know which Data Extension was used which would give me the email address used.
So - I can retrieve Sends, which has Email and EmailSendDefinition unfortunately I cannot Retrieve the objects Email or EmailSendDefinition since they're not supported by the method. By adding "EmailSendDefinition.CustomerKey" my Request retrieves the Send data but I cannot then access the CustomerKey because it's not instantiated - ie
Can anyone point me in the right direction? or explain what the code (.Net C#) is doing wrong? or advise of a better method to meet the requirement?
Code is
RetrieveRequest rr = new RetrieveRequest();
rr.ObjectType = "Send";
String[] props = { "ID", "EmailName", "Status", "EmailSendDefinition.CustomerKey", "Client.ID"};
rr.Properties = props;
APIObject[] results = null;
String requestID = null;
string status = null;
APIObject[] lSources = null;
Send se = null;
do
{
status = etFramework.Retrieve(rr, out requestID, out results);
for (int i = 0; i < results.Length; i++)
{
//se = (Send)results[i];
se = results[i] as Send;
SendOutputBuffer.AddRow();
SendOutputBuffer.EmailName = se.EmailName;
SendOutputBuffer.SendID=se.ID;
SendOutputBuffer.Status=se.Status;
if (se.EmailSendDefinition != null)
MessageBox.Show(se.EmailSendDefinition.CustomerKey);
}
//This call the API again to get the next 2500 records
rr = new RetrieveRequest();
rr.ContinueRequest = requestID;
} while (status.Equals("MoreDataAvailable"));//This means there are more than 2500 records