コード例 #1
0
 public static void Main(string[] args)
 {
     using (var client = new AmazonPinpointClient(RegionEndpoint.GetBySystemName(region)))
     {
         var sendRequest = new SendMessagesRequest
         {
             ApplicationId  = appId,
             MessageRequest = new MessageRequest
             {
                 Addresses = new Dictionary <string, AddressConfiguration>
                 {
                     {
                         toAddress,
                         new AddressConfiguration
                         {
                             ChannelType = "EMAIL"
                         }
                     }
                 },
                 MessageConfiguration = new DirectMessageConfiguration
                 {
                     EmailMessage = new EmailMessage
                     {
                         FromAddress = senderAddress,
                         SimpleEmail = new SimpleEmail
                         {
                             HtmlPart = new SimpleEmailPart
                             {
                                 Charset = charset,
                                 Data    = htmlBody
                             },
                             TextPart = new SimpleEmailPart
                             {
                                 Charset = charset,
                                 Data    = textBody
                             },
                             Subject = new SimpleEmailPart
                             {
                                 Charset = charset,
                                 Data    = subject
                             }
                         }
                     }
                 }
             }
         };
         try
         {
             Console.WriteLine("Sending message...");
             SendMessagesResponse response = client.SendMessages(sendRequest);
             Console.WriteLine("Message sent!");
         }
         catch (Exception ex)
         {
             Console.WriteLine("The message wasn't sent. Error message: " + ex.Message);
         }
     }
 }
コード例 #2
0
 public static void Main(string[] args)
 {
     using (AmazonPinpointClient client = new AmazonPinpointClient(RegionEndpoint.GetBySystemName(region)))
     {
         SendMessagesRequest sendRequest = new SendMessagesRequest
         {
             ApplicationId  = appId,
             MessageRequest = new MessageRequest
             {
                 Addresses = new Dictionary <string, AddressConfiguration>
                 {
                     {
                         destinationNumber,
                         new AddressConfiguration
                         {
                             ChannelType = "SMS"
                         }
                     }
                 },
                 MessageConfiguration = new DirectMessageConfiguration
                 {
                     SMSMessage = new SMSMessage
                     {
                         Body              = message,
                         MessageType       = messageType,
                         OriginationNumber = originationNumber,
                         SenderId          = senderId,
                         Keyword           = registeredKeyword
                     }
                 }
             }
         };
         try
         {
             Console.WriteLine("Sending message...");
             SendMessagesResponse response = client.SendMessages(sendRequest);
             Console.WriteLine("Message sent!");
         }
         catch (Exception ex)
         {
             Console.WriteLine("The message wasn't sent. Error message: " + ex.Message);
         }
     }
 }