public SendEmailAsync ( SendEmailRequest request, System cancellationToken = default(CancellationToken) ) : Task |
||
request | SendEmailRequest | Container for the necessary parameters to execute the SendEmail operation. |
cancellationToken | System | /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// |
return | Task |
/// <summary> /// Send the email message /// </summary> /// <param name="messageBody">the body text to include in the mail</param> protected virtual void SendEmail(string messageBody) { // Create the email object first, then add the properties. var subject = new Content(Subject); Body body = new Body(); if (IsBodyHTML) { body.Html = new Content(messageBody); } else { body.Text = new Content(messageBody); } var destination = new Destination(); var msg = new Message(subject, body); destination.ToAddresses = m_to.Split(ADDRESS_DELIMITERS).ToList(); if (!String.IsNullOrWhiteSpace(m_cc)) { destination.CcAddresses = m_cc.Split(ADDRESS_DELIMITERS).ToList(); } if (!String.IsNullOrWhiteSpace(m_bcc)) { destination.BccAddresses = m_bcc.Split(ADDRESS_DELIMITERS).ToList(); } var request = new SendEmailRequest(From, destination, msg); var credentials = new Amazon.Runtime.BasicAWSCredentials(AccessKey, SecretKey); var client = new AmazonSimpleEmailServiceClient(credentials, Amazon.RegionEndpoint.EUWest1); try { client.SendEmailAsync(request); } catch (Exception ex) { ErrorHandler.Error("Error occurred while sending e-mail notification.", ex); } }