示例#1
0
 private static void GetClient(IExactTargetConfiguration config)
 {
     _SharedClent = new SharedRequestClient(config);
     triggeredSendDefinitionClient = new TriggeredSendDefinitionClient(config);
     _dataExtensionClient          = new DataExtensionClient(config);
     _deliveryProfileClient        = new DeliveryProfileClient(config);
     _Client = SoapClientFactory.Manufacture(config);
 }
 public EmailRequestClient(IExactTargetConfiguration config)
 {
     _config = config;
     _client = SoapClientFactory.Manufacture(config);
     _emailFromTemplateCreator = new EmailCreator(new ExactTargetConfiguration
     {
         ApiUserName = _config.ApiUserName,
         ApiPassword = _config.ApiPassword,
         ClientId    = _config.ClientId,
         EndPoint    = _config.EndPoint,
         SoapBinding = _config.SoapBinding
     });
 }
        public void TriggerCustom(TriggeredSendDataModel exactTargetTriggeredEmail, List <Subscriber> lst, RequestQueueing requestQueueing = RequestQueueing.No, Utlities.Priority priority = Utlities.Priority.Normal)
        {
            var clientId = _config.ClientId;
            var client   = SoapClientFactory.Manufacture(_config);

            var tsd = new TriggeredSendDefinition
            {
                Client = clientId.HasValue ? new ClientID {
                    ID = clientId.Value, IDSpecified = true
                } : null,
                CustomerKey = exactTargetTriggeredEmail.TriggerSendDefinitionExternalKey,
            };

            var ts = new TriggeredSend
            {
                Client = clientId.HasValue ? new ClientID {
                    ID = clientId.Value, IDSpecified = true
                } : null,
                TriggeredSendDefinition = tsd,
                Subscribers             = lst.ToArray(),
            };

            var co = new CreateOptions
            {
                RequestType            = requestQueueing == RequestQueueing.No ? RequestType.Synchronous : RequestType.Asynchronous,
                RequestTypeSpecified   = true,
                QueuePriority          = priority == Utlities.Priority.High ? ETService.Priority.High : ETService.Priority.Medium,
                QueuePrioritySpecified = true
            };

            string requestId, status;
            var    result = client.Create(
                co,
                new APIObject[] { ts },
                out requestId, out status);

            ExactTargetResultChecker.CheckResult(result.FirstOrDefault()); //we expect only one result because we've sent only one APIObject
        }
示例#4
0
 public SharedRequestClient(IExactTargetConfiguration config)
 {
     _client = SoapClientFactory.Manufacture(config);
     _config = config;
 }
 public TriggeredSendDefinitionClient(IExactTargetConfiguration config)
 {
     _config = config;
     _client = SoapClientFactory.Manufacture(config);
     _sharedCoreRequestClient = new SharedRequestClient(config);
 }
 public EmailRequestClient(IExactTargetConfiguration config, IEmailCreator emailFromTemplateCreator)
 {
     _config = config;
     _client = SoapClientFactory.Manufacture(config);
     _emailFromTemplateCreator = emailFromTemplateCreator;
 }
示例#7
0
 public EmailTemplateClient(IExactTargetConfiguration config)
 {
     _client = SoapClientFactory.Manufacture(config);
     _config = config;
 }
示例#8
0
 public DataExtensionClient(IExactTargetConfiguration config)
 {
     _config = config;
     _client = SoapClientFactory.Manufacture(config);
     _sharedCoreRequestClient = new SharedCoreRequestClient(config);
 }
示例#9
0
 public DeliveryProfileClient(IExactTargetConfiguration config)
 {
     _config = config;
     _client = SoapClientFactory.Manufacture(config);
 }
示例#10
0
        public void Trigger(ExactTargetTriggeredEmail exactTargetTriggeredEmail, RequestQueueing requestQueueing = RequestQueueing.No, Priority priority = Priority.Normal)
        {
            var clientId = _config.ClientId;
            var client   = SoapClientFactory.Manufacture(_config);

            var subscriber = new Subscriber
            {
                EmailAddress  = exactTargetTriggeredEmail.EmailAddress,
                SubscriberKey = exactTargetTriggeredEmail.SubscriberKey ?? exactTargetTriggeredEmail.EmailAddress,
                Attributes    =
                    exactTargetTriggeredEmail.ReplacementValues.Select(value => new Attribute
                {
                    Name  = value.Key,
                    Value = value.Value
                }).ToArray()
            };

            // Add sender information if specified. This will send the email with FromAddress in the sender field.
            // Official doco here under the section "Determining the From Information at Send Time":
            // https://help.exacttarget.com/en/technical_library/web_service_guide/triggered_email_scenario_guide_for_developers/#Determining_the_From_Information_at_Send_Time
            if (!string.IsNullOrEmpty(exactTargetTriggeredEmail.FromAddress) && !string.IsNullOrEmpty(exactTargetTriggeredEmail.FromName))
            {
                subscriber.Owner = new Owner()
                {
                    FromAddress = exactTargetTriggeredEmail.FromAddress,
                    FromName    = exactTargetTriggeredEmail.FromName
                };
            }

            var subscribers = new List <Subscriber> {
                subscriber
            };

            var tsd = new TriggeredSendDefinition
            {
                Client = clientId.HasValue ? new ClientID {
                    ID = clientId.Value, IDSpecified = true
                } : null,
                CustomerKey = exactTargetTriggeredEmail.ExternalKey
            };

            var ts = new TriggeredSend
            {
                Client = clientId.HasValue ? new ClientID {
                    ID = clientId.Value, IDSpecified = true
                } : null,
                TriggeredSendDefinition = tsd,
                Subscribers             = subscribers.ToArray()
            };

            var co = new CreateOptions
            {
                RequestType            = requestQueueing == RequestQueueing.No ? RequestType.Synchronous : RequestType.Asynchronous,
                RequestTypeSpecified   = true,
                QueuePriority          = priority == Priority.High ? ExactTargetApi.Priority.High : ExactTargetApi.Priority.Medium,
                QueuePrioritySpecified = true
            };

            string requestId, status;
            var    result = client.Create(
                co,
                new APIObject[] { ts },
                out requestId, out status);

            ExactTargetResultChecker.CheckResult(result.FirstOrDefault()); //we expect only one result because we've sent only one APIObject
        }