public SendReturnStatus CreateTriggeredSendEmail(string name, string customerKey, string description, string subject, string htmlBody, string emailAddress) { try { string triggeredEndCustomerKey = CreateTriggeredSendDefinition(name, customerKey, description, subject, htmlBody); //string triggeredEndCustomerKey = CreateTriggeredSendDefinition(name, customerKey, description, subject, htmlBody); ET_TriggeredSend tsdSendNew = new ET_TriggeredSend(); tsdSendNew.AuthStub = _etClient; tsdSendNew.CustomerKey = triggeredEndCustomerKey; tsdSendNew.Subscribers = new ET_Subscriber[] { new ET_Subscriber() { EmailAddress = emailAddress, SubscriberKey = emailAddress } }; SendReturn srSendnew = tsdSendNew.Send(); return(new SendReturnStatus() { Status = srSendnew.Status.ToString(), Message = srSendnew.Message.ToString(), Code = srSendnew.Code.ToString(), ResultsLength = srSendnew.Results.Length }); } catch (Exception ex) { throw; } }
public void ProcessDailyAdditions() { String strTimeToRun = Sitecore.Configuration.Settings.GetAppSetting("CronJob.TimeToRun"); if (!String.IsNullOrWhiteSpace(strTimeToRun)) { TimeSpan TimeToRun = DateTime.Parse(strTimeToRun).TimeOfDay; Boolean IsItTime = DateTime.Now.TimeOfDay.Subtract(TimeToRun).Ticks > 0; if (IsItTime) { } } string spName = "prcSelectDailyList"; DataTable dt = GetApprovedItems(spName); foreach (DataRow dr in dt.Rows) { NameValueCollection parameters = new NameValueCollection(); parameters.Add("clientId", "3uqagf2nrt2mm27q3rt45ett"); parameters.Add("clientSecret", "D5wxtEx6UGNVxgkbyrruJhQV"); ET_Client myclient = new ET_Client(parameters); ET_TriggeredSend triggeredsend = new ET_TriggeredSend(); triggeredsend.AuthStub = myclient; triggeredsend.Name = "SDKTriggeredSend"; triggeredsend.CustomerKey = "test_email_ram_mip"; triggeredsend.Subscribers = new ET_Subscriber[1]; triggeredsend.Subscribers[0] = new ET_Subscriber(); triggeredsend.Subscribers[0].EmailAddress = "*****@*****.**"; triggeredsend.Subscribers[0].SubscriberKey = "*****@*****.**"; //triggeredsend.Email = new ET_Email() { ID = 1111111 }; //triggeredsend.SendClassification = new ET_SendClassification() { CustomerKey = "2222" }; //PostReturn prtriggeredsend = triggeredsend.Post(); SendReturn srSend = triggeredsend.Send(); //Sitecore.Diagnostics.Log.Info("Send Status: " + srSend.Status.ToString(), this); //Sitecore.Diagnostics.Log.Info("Message: " + srSend.Message.ToString(), this); //Sitecore.Diagnostics.Log.Info("Code: " + srSend.Code.ToString(), this); // ET_TriggeredSend triggeredsend = new ET_TriggeredSend(); // triggeredsend.AuthStub = myclient; // triggeredsend.Name = "SDKTriggeredSend"; // triggeredsend.CustomerKey = "test_email_ram_mip11"; // triggeredsend.Email = new ET_Email() { ID = 1111111 }; //triggeredsend.SendClassification = new ET_SendClassification() { CustomerKey = "test_email_ram_mip11" }; // PostReturn prtriggeredsend = triggeredsend.Post(); // Console.WriteLine("Post Status: " + prtriggeredsend.Status.ToString()); // Sitecore.Diagnostics.Log.Info("Results Length: " + prtriggeredsend.Results.Length, this); } }
static void TestET_TriggeredSend() { var myclient = new ET_Client(); Console.WriteLine("--- Testing TriggeredSend ---"); var tsNameForCreateThenDelete = Guid.NewGuid().ToString(); var existingTSDCustomerKey = "TEXTEXT"; Console.WriteLine("\n Send Using an Existing Definition "); var tsdSend = new ET_TriggeredSend { AuthStub = myclient, CustomerKey = existingTSDCustomerKey, Subscribers = new[] { new ET_Subscriber { EmailAddress = "*****@*****.**", SubscriberKey = "*****@*****.**" } }, }; var srSend = tsdSend.Send(); Console.WriteLine("Send Status: " + srSend.Status.ToString()); Console.WriteLine("Message: " + srSend.Message); Console.WriteLine("Code: " + srSend.Code.ToString()); Console.WriteLine("Results Length: " + srSend.Results.Length); Console.WriteLine("\n Retrieve All TriggeredSend Definitions"); var tsdGetAll = new ET_TriggeredSend { AuthStub = myclient, Props = new[] { "CustomerKey", "Name", "TriggeredSendStatus" }, SearchFilter = new SimpleFilterPart { Property = "CustomerKey", SimpleOperator = SimpleOperators.equals, Value = new[] { tsNameForCreateThenDelete } }, }; var grAllTSD = tsdGetAll.Get(); Console.WriteLine("Get Status: " + grAllTSD.Status.ToString()); Console.WriteLine("Message: " + grAllTSD.Message); Console.WriteLine("Code: " + grAllTSD.Code.ToString()); Console.WriteLine("Results Length: " + grAllTSD.Results.Length); foreach (ET_TriggeredSend result in grAllTSD.Results) { Console.WriteLine("--CustomerKey: " + result.CustomerKey + ", Name: " + result.Name + ", Status: " + result.TriggeredSendStatus.ToString()); } Console.WriteLine("\n Create a TriggeredSend Definition"); var tsd = new ET_TriggeredSend { AuthStub = myclient, Name = tsNameForCreateThenDelete, CustomerKey = tsNameForCreateThenDelete, Email = new ET_Email { ID = 3113962 }, SendClassification = new ET_SendClassification { CustomerKey = "2240" }, }; var prTSD = tsd.Post(); Console.WriteLine("Post Status: " + prTSD.Status.ToString()); Console.WriteLine("Message: " + prTSD.Message); Console.WriteLine("Code: " + prTSD.Code.ToString()); Console.WriteLine("Results Length: " + prTSD.Results.Length); Console.WriteLine("\n Retrieve Single TriggeredSend"); var tsdGet = new ET_TriggeredSend { AuthStub = myclient, Props = new[] { "CustomerKey", "Name", "TriggeredSendStatus" }, SearchFilter = new SimpleFilterPart { Property = "CustomerKey", SimpleOperator = SimpleOperators.equals, Value = new[] { tsNameForCreateThenDelete } }, }; var tsdGetSingle = tsdGet.Get(); Console.WriteLine("Get Status: " + tsdGetSingle.Status.ToString()); Console.WriteLine("Message: " + tsdGetSingle.Message); Console.WriteLine("Code: " + tsdGetSingle.Code.ToString()); Console.WriteLine("Results Length: " + tsdGetSingle.Results.Length); foreach (ET_TriggeredSend result in tsdGetSingle.Results) { Console.WriteLine("--CustomerKey: " + result.CustomerKey + ", Name: " + result.Name + ", Status: " + result.TriggeredSendStatus.ToString()); } Console.WriteLine("\n Start a TriggeredSend by setting to Active"); var tsdPatch = new ET_TriggeredSend { AuthStub = myclient, CustomerKey = tsNameForCreateThenDelete, TriggeredSendStatus = TriggeredSendStatusEnum.Active, }; var patchrTSD = tsdPatch.Patch(); Console.WriteLine("Patch Status: " + patchrTSD.Status.ToString()); Console.WriteLine("Message: " + patchrTSD.Message); Console.WriteLine("Code: " + patchrTSD.Code.ToString()); Console.WriteLine("Results Length: " + patchrTSD.Results.Length); Console.WriteLine("\n Retrieve Single TriggeredSend After setting to active"); tsdGetSingle = tsdGet.Get(); Console.WriteLine("Get Status: " + tsdGetSingle.Status.ToString()); Console.WriteLine("Message: " + tsdGetSingle.Message); Console.WriteLine("Code: " + tsdGetSingle.Code.ToString()); Console.WriteLine("Results Length: " + tsdGetSingle.Results.Length); foreach (ET_TriggeredSend result in tsdGetSingle.Results) { Console.WriteLine("--CustomerKey: " + result.CustomerKey + ", Name: " + result.Name + ", Status: " + result.TriggeredSendStatus.ToString()); } Console.WriteLine("\n Send using new definition"); var tsdSendNew = new ET_TriggeredSend { AuthStub = myclient, CustomerKey = tsNameForCreateThenDelete, Subscribers = new[] { new ET_Subscriber { EmailAddress = "*****@*****.**", SubscriberKey = "*****@*****.**" } }, }; var srSendnew = tsdSendNew.Send(); Console.WriteLine("Send Status: " + srSendnew.Status.ToString()); Console.WriteLine("Message: " + srSendnew.Message); Console.WriteLine("Code: " + srSendnew.Code.ToString()); Console.WriteLine("Results Length: " + srSendnew.Results.Length); Console.WriteLine("\n Pause a TriggeredSend by setting to Inactive"); tsdPatch.TriggeredSendStatus = TriggeredSendStatusEnum.Inactive; patchrTSD = tsdPatch.Patch(); Console.WriteLine("Patch Status: " + patchrTSD.Status.ToString()); Console.WriteLine("Message: " + patchrTSD.Message); Console.WriteLine("Code: " + patchrTSD.Code.ToString()); Console.WriteLine("Results Length: " + patchrTSD.Results.Length); Console.WriteLine("\n Delete a TriggeredSend Definition"); var tsdDelete = new ET_TriggeredSend { AuthStub = myclient, CustomerKey = tsNameForCreateThenDelete, }; var drTSD = tsdDelete.Delete(); Console.WriteLine("Delete Status: " + drTSD.Status.ToString()); Console.WriteLine("Message: " + drTSD.Message); Console.WriteLine("Code: " + drTSD.Code.ToString()); Console.WriteLine("Results Length: " + drTSD.Results.Length); }