public void Send(Email email) { using (var mailMessage = CreateMailMessage(email)) { _simpleEmailService.SendEmail(CreateSendEmailRequest(mailMessage)); } }
public AmazonWebServiceResponse ExecuteService(ValidationResult param, AmazonSimpleEmailService emailService) { var destination = new Destination() .WithToAddresses(param.EmailAddresses) .WithCcAddresses(param.CC) .WithBccAddresses(param.BCC); emailService.SendEmail(new SendEmailRequest(param.SenderEmail,destination, GetMessage(param.Subject, param.Body))); return null; }
public static Boolean SendEmail(String From, String To, String Subject, String Text = null, String HTML = null, String emailReplyTo = null, String returnPath = null) { if (Text != null || HTML != null) { String from = From; List <String> to = To .Replace(", ", ",") .Split(',') .ToList(); Destination destination = new Destination(); destination.WithToAddresses(to); //destination.WithCcAddresses(cc); //destination.WithBccAddresses(bcc); Content subject = new Content(); subject.WithCharset("UTF-8"); subject.WithData(Subject); Body body = new Body(); if (HTML != null) { Content html = new Content(); html.WithCharset("UTF-8"); html.WithData(HTML); body.WithHtml(html); } if (Text != null) { Content text = new Content(); text.WithCharset("UTF-8"); text.WithData(Text); body.WithText(text); } Message message = new Message(); message.WithBody(body); message.WithSubject(subject); string awsAccessKey = AWSAccessKey; string awsSecretKey = AWSSecretKey; //AmazonSimpleEmailService ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(AppConfig["AWSAccessKey"], AppConfig["AWSSecretKey"]); AmazonSimpleEmailService ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(awsAccessKey, awsSecretKey); SendEmailRequest request = new SendEmailRequest(); request.WithDestination(destination); request.WithMessage(message); request.WithSource(from); if (emailReplyTo != null) { List <String> replyto = emailReplyTo .Replace(", ", ",") .Split(',') .ToList(); request.WithReplyToAddresses(replyto); } if (returnPath != null) { request.WithReturnPath(returnPath); } try { SendEmailResponse response = ses.SendEmail(request); SendEmailResult result = response.SendEmailResult; Console.WriteLine("Email sent."); Console.WriteLine(String.Format("Message ID: {0}", result.MessageId)); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; return(false); } } Console.WriteLine("Specify Text and/or HTML for the email body!"); return(false); }
public static Boolean SendEmail(String From, Recipient recipient, String Subject, String Text = null, String HTML = null, String emailReplyTo = null, String returnPath = null) { if (Text != null && HTML != null) { String from = From; List <String> to = recipient.Email .Replace(", ", ",") .Split(',') .ToList(); Destination destination = new Destination(); destination.WithToAddresses(recipient.Email); //destination.WithCcAddresses(cc); //destination.WithBccAddresses(bcc); Content subject = new Content(); subject.WithCharset("UTF-8"); subject.WithData(Subject); Content html = new Content(); html.WithCharset("UTF-8"); html.WithData(HTML); Content text = new Content(); text.WithCharset("UTF-8"); text.WithData(Text); Body body = new Body(); body.WithHtml(html); body.WithText(text); Message message = new Message(); message.WithBody(body); message.WithSubject(subject); string accessKey = ConfigurationManager.AppSettings["AWSAccessKey"]; string secretKey = ConfigurationManager.AppSettings["AWSSecretKey"]; AmazonSimpleEmailService ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(accessKey, secretKey); SendEmailRequest request = new SendEmailRequest(); request.WithDestination(destination); request.WithMessage(message); request.WithSource(from); if (emailReplyTo != null) { List <String> replyto = emailReplyTo .Replace(", ", ",") .Split(',') .ToList(); request.WithReplyToAddresses(replyto); } if (returnPath != null) { request.WithReturnPath(returnPath); } try { SendEmailResponse response = ses.SendEmail(request); SendEmailResult result = response.SendEmailResult; return(true); } catch (Exception ex) { recipient.ErrorMessage = ex.Message; return(false); } } throw new Exception("Specify Text and/or HTML for the email body!"); }
/// <summary> /// Sends a formatted email. /// </summary> /// <param name="request"> /// A <see cref="SendEmailRequest" /> object. /// </param> /// <returns> /// The unique <see cref="Message" /> ID for the email. /// </returns> internal string SendFormattedEmail(SendEmailRequest request) { SendEmailResponse response = _sesClient.SendEmail(request); return(response != null && response.SendEmailResult != null ? response.SendEmailResult.MessageId : string.Empty); }
///<Summary> /// Gets the answer ///</Summary> public static Boolean SendEmail(String From, String To, String Subject, String Text = null, String HTML = null, String emailReplyTo = null, String returnPath = null) { if (Text != null && HTML != null) { String from = From; List <String> to = To .Replace(", ", ",") .Split(',') .ToList(); Destination destination = new Destination(); destination.WithToAddresses(to); //destination.WithCcAddresses(cc); //destination.WithBccAddresses(bcc); Amazon.SimpleEmail.Model.Content subject = new Amazon.SimpleEmail.Model.Content(); subject.WithCharset("UTF-8"); subject.WithData(Subject); Amazon.SimpleEmail.Model.Content html = new Amazon.SimpleEmail.Model.Content(); html.WithCharset("UTF-8"); html.WithData(HTML); Amazon.SimpleEmail.Model.Content text = new Amazon.SimpleEmail.Model.Content(); text.WithCharset("UTF-8"); text.WithData(Text); Body body = new Body(); body.WithHtml(html); body.WithText(text); Amazon.SimpleEmail.Model.Message message = new Amazon.SimpleEmail.Model.Message(); message.WithBody(body); message.WithSubject(subject); AmazonSimpleEmailService ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(AppConfig["AWSAccessKey"], AppConfig["AWSSecretKey"]); SendEmailRequest request = new SendEmailRequest(); request.WithDestination(destination); request.WithMessage(message); request.WithSource(from); if (emailReplyTo != null) { List <String> replyto = emailReplyTo .Replace(", ", ",") .Split(',') .ToList(); request.WithReplyToAddresses(replyto); } if (returnPath != null) { request.WithReturnPath(returnPath); } try { SendEmailResponse response = ses.SendEmail(request); SendEmailResult result = response.SendEmailResult; return(true); } catch { return(false); } } return(false); }