Пример #1
0
        public async Task SendMemory(string memoryToSend, string fromEmailAddress, List <string> targetEmailAddresses)
        {
            // check to see if targeted emails are verified
            var verificationAttributesResponse = await _ses.GetIdentityVerificationAttributesAsync(new GetIdentityVerificationAttributesRequest
            {
                Identities = new List <string>(targetEmailAddresses)
            });

            // ensure emails are verified, then send to all verified email addresses
            var emailIndex = 0;

            while (emailIndex < targetEmailAddresses.Count)
            {
                var email = targetEmailAddresses[emailIndex];
                if (!verificationAttributesResponse.VerificationAttributes.ContainsKey(email) ||
                    verificationAttributesResponse.VerificationAttributes[email].VerificationStatus.Value != "Success")
                {
                    // send request to verify email
                    await _ses.VerifyEmailIdentityAsync(new VerifyEmailIdentityRequest
                    {
                        EmailAddress = email
                    });

                    // remove from list of emails to send to this time
                    targetEmailAddresses.RemoveAt(emailIndex);
                }
                else
                {
                    emailIndex++;
                }
            }

            // send email(s)
            await _ses.SendEmailAsync(new SendEmailRequest
            {
                Source      = fromEmailAddress,
                Destination = new Destination(targetEmailAddresses),
                Message     = new Message
                {
                    Body    = new Body(new Content(memoryToSend)),
                    Subject = new Content("thinking of you")
                }
            });
        }
Пример #2
0
 private Amazon.SimpleEmail.Model.GetIdentityVerificationAttributesResponse CallAWSServiceOperation(IAmazonSimpleEmailService client, Amazon.SimpleEmail.Model.GetIdentityVerificationAttributesRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Email Service (SES)", "GetIdentityVerificationAttributes");
     try
     {
         #if DESKTOP
         return(client.GetIdentityVerificationAttributes(request));
         #elif CORECLR
         return(client.GetIdentityVerificationAttributesAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }