コード例 #1
0
ファイル: Program.cs プロジェクト: erlizhou/SampleCPMProject
        /// <summary>
        /// Given a list of email addresses and a particular topic id, check if those email contact values
        /// can be contacted by the topic id.
        /// This end point is pessimistic, in that if CPM does not know about the contact value or if the contact value does not know about the topic,
        /// the "CanContact" value will always return false.
        /// </summary>
        /// <param name="emailAddresses">The list of email addresses to check. Maximum size 50.</param>
        /// <param name="topicId">The topic id".</param>
        /// <returns></returns>
        private static async Task GetEmailContactabilities(List <string> emailAddresses, Guid topicId)
        {
            EmailContactabilitiesRequest request = new EmailContactabilitiesRequest()
            {
                TargetedTopicId = topicId
            };

            foreach (string emailAddress in emailAddresses)
            {
                request.ContactPoints.Add(emailAddress);
            }

            using (HttpClient client = await CPMClientGenerator.CreateHttpClientAsync())
            {
                HttpResponseMessage response = await client.PostAsJsonAsync("/api/EmailContactabilities", request);

                if (response.IsSuccessStatusCode)
                {
                    EmailContactabilitiesResponse result = await response.Content.ReadAsAsync <EmailContactabilitiesResponse>();

                    Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
                }
                else
                {
                    Console.WriteLine(await response.Content.ReadAsStringAsync());
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: v-satyar/SampleCPMProject
        /// <summary>
        /// Given a list of email addresses and a particular topic id, check if those email contact values
        /// can be contacted by the topic id.
        /// This end point is pessimistic, in that if CPM does not know about the contact value or if the contact value does not know about the topic,
        /// the "CanContact" value will always return false.
        /// </summary>
        private static void GetEmailContactabilities()
        {
            var emails = new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**" };

            EmailContactabilitiesRequest request = new EmailContactabilitiesRequest()
            {
                TargetedTopicId = testTopicId,                                 //Topic Id for which you want to contact customers

                /*If the UnsubscribeUrlRequired field is set to true CPM will return a URL that customers can use to unsubscribe from this communication.
                 * This URL will only be returned for customers for whom canContact = true.
                 * This URL is meant to be included in the email communication that is sent to the customer
                 */
                UnsubscribeUrlRequired = true
            };

            foreach (string emailAddress in emails)
            {
                request.ContactPoints.Add(emailAddress);
            }

            EmailContactabilitiesResponse result = cpmClient.GetEmailContactability(request).Result;

            Console.WriteLine(JsonConvert.SerializeObject(result));
        }