SendRawEmail() public method

Sends an email message, with header and content specified by the client. The SendRawEmail action is useful for sending multipart MIME emails. The raw text of the message must comply with Internet email standards; otherwise, the message cannot be sent.

There are several important points to know about SendRawEmail:

  • You can only send email from verified email addresses and domains; otherwise, you will get an "Email address not verified" error. If your account is still in the Amazon SES sandbox, you must also verify every recipient email address except for the recipients provided by the Amazon SES mailbox simulator. For more information, go to the Amazon SES Developer Guide.

  • The total size of the message cannot exceed 10 MB. This includes any attachments that are part of the message.

  • Amazon SES has a limit on the total number of recipients per message. The combined number of To:, CC: and BCC: email addresses cannot exceed 50. If you need to send an email message to a larger audience, you can divide your recipient list into groups of 50 or fewer, and then call Amazon SES repeatedly to send the message to each group.

  • The To:, CC:, and BCC: headers in the raw message can contain a group list. Note that each recipient in a group list counts towards the 50-recipient limit.

  • Amazon SES overrides any Message-ID and Date headers you provide.

  • For every message that you send, the total number of recipients (To:, CC: and BCC:) is counted against your sending quota - the maximum number of emails you can send in a 24-hour period. For information about your sending quota, go to the Amazon SES Developer Guide.

  • If you are using sending authorization to send on behalf of another user, SendRawEmail enables you to specify the cross-account identity for the email's "Source," "From," and "Return-Path" parameters in one of two ways: you can pass optional parameters SourceArn, FromArn, and/or ReturnPathArn to the API, or you can include the following X-headers in the header of your raw email:

    • X-SES-SOURCE-ARN

    • X-SES-FROM-ARN

    • X-SES-RETURN-PATH-ARN

    Do not include these X-headers in the DKIM signature, because they are removed by Amazon SES before sending the email.

    For the most common sending authorization use case, we recommend that you specify the SourceIdentityArn and do not specify either the FromIdentityArn or ReturnPathIdentityArn. (The same note applies to the corresponding X-headers.) If you only specify the SourceIdentityArn, Amazon SES will simply set the "From" address and the "Return Path" address to the identity specified in SourceIdentityArn. For more information about sending authorization, see the Amazon SES Developer Guide.

/// Indicates that the configuration set does not exist. /// /// Indicates that the message could not be sent because Amazon SES could not read the /// MX record required to use the specified MAIL FROM domain. For information about editing /// the custom MAIL FROM domain settings for an identity, see the Amazon /// SES Developer Guide. /// /// Indicates that the action failed, and the message could not be sent. Check the error /// stack for more information about what caused the error. ///
public SendRawEmail ( SendRawEmailRequest request ) : SendRawEmailResponse
request SendRawEmailRequest Container for the necessary parameters to execute the SendRawEmail service method.
return SendRawEmailResponse
示例#1
0
    public static void SESSendRawEmail()
    {
      #region SESSendRawEmail
      // using System.IO;

      var sesClient = new AmazonSimpleEmailServiceClient();

      var stream = new MemoryStream(
        Encoding.UTF8.GetBytes("From: [email protected]\n" +
          "To: [email protected]\n" +
          "Subject: You're invited to the meeting\n" +
          "Content-Type: text/plain\n\n" +
          "Please join us Monday at 7:00 PM.")
      );

      var raw = new RawMessage
      {
        Data = stream
      };

      var to = new List<string>() { "*****@*****.**" };
      var from = "*****@*****.**";

      var request = new SendRawEmailRequest
      {
        Destinations = to,
        RawMessage = raw,
        Source = from
      };

      sesClient.SendRawEmail(request);
      #endregion
    }
示例#2
0
    public static string sendInvEmail(string email, string subject, string msg, string attach1, string attach2)
    {
        try
        {
            Amazon.SimpleEmail.AmazonSimpleEmailServiceConfig config = new Amazon.SimpleEmail.AmazonSimpleEmailServiceConfig();
            config.RegionEndpoint = Amazon.RegionEndpoint.USEast1;
            Amazon.SimpleEmail.AmazonSimpleEmailServiceClient client = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient("AKIAI6NU4VLLI32AI2UA", Cryptography.Decrypt("NdL0xWLhvbF6pvu3hw1FtluhPmUc1jAuWKgj6mb4V89KztEq6MjEhQoiCPLVv4y9"), config);
            var         stream     = new MemoryStream();
            MimeMessage objMessage = new MimeMessage();
            string[]    emls       = email.Split(',');
            foreach (string eml in emls)
            {
                objMessage.To.Add(new MailboxAddress(string.Empty, eml));
            }
            objMessage.From.Add(new MailboxAddress("InfnIT Invoice", "*****@*****.**"));
            objMessage.Subject = subject;
            BodyBuilder emailBodyObj = new BodyBuilder();
            emailBodyObj.HtmlBody = msg;
            emailBodyObj.Attachments.Add(attach1);
            emailBodyObj.Attachments.Add(attach2);
            objMessage.Body = emailBodyObj.ToMessageBody();
            objMessage.WriteTo(stream);
            Amazon.SimpleEmail.Model.SendRawEmailRequest mailObj = new Amazon.SimpleEmail.Model.SendRawEmailRequest(new RawMessage(stream));
            SendRawEmailResponse response = client.SendRawEmail(mailObj);
            string res = response.MessageId;

            System.Net.Mail.MailMessage aMessage = new System.Net.Mail.MailMessage();
            aMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "InfnIT Invoice");

            //aMessage.To.Add(email);
            //aMessage.ReplyTo = new System.Net.Mail.MailAddress("*****@*****.**");
            //aMessage.Subject = subject;
            //System.Net.Mail.AlternateView htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(msg, System.Text.Encoding.UTF8, "text/html");
            //aMessage.IsBodyHtml = true;
            //aMessage.BodyEncoding = System.Text.Encoding.UTF8;
            //aMessage.Attachments.Add(new System.Net.Mail.Attachment(attach1));
            //aMessage.Attachments.Add(new System.Net.Mail.Attachment(attach2));

            //aMessage.AlternateViews.Add(htmlView);
            //System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient();
            //mailClient.Host = "smtp.gmail.com";
            //mailClient.Port = 587;
            //mailClient.EnableSsl = true;
            //mailClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "m4iling2");

            //mailClient.Send(aMessage);

            return("success");//downloadCfdi += "<p>Correo enviado";
        }
        catch (Exception ex)
        {
            return(ex.Message);
            //downloadCfdi += "<p><i class=\"w3-red\">No se pudo enviar el correo: +" + ex.Message + "</i>";
        }
    }
        public static void Send(string from, string to, string bcc, string subject, string body)
        {
            using (var client = new AmazonSimpleEmailServiceClient(Settings.AccessKey, Settings.Secret, RegionEndpoint.USWest2))
            {
                var request = new SendRawEmailRequest
                {
                    Source = from,
                    Destinations = new List<string> { to, bcc },
                    RawMessage = CreateMessage(from, to, bcc, subject, body)
                };

                client.SendRawEmail(request);
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Press any key to send mail!");
            Console.ReadKey();
            //Getting AWS credentials from App.config
            //note: see the app.config to get a example
            var credentials = new EnvironmentAWSCredentials();

            //Client SES instantiated
            var client = new AmazonSimpleEmailServiceClient(credentials, RegionEndpoint.USEast1);
            var mimeMessage = new MimeMessage();

            //Add sender e-mail address
            //Note: this e-mail address must to be allowed and checked by AWS SES
            mimeMessage.From.Add(new MailboxAddress("Test Sender", "*****@*****.**"));

            //Add  e-mail address destiny
            mimeMessage.To.Add(new MailboxAddress("Joel", "*****@*****.**"));
            mimeMessage.Subject = "Test";
            //Getting attachment stream
            var fileBytes = File.ReadAllBytes(@"C:\anyfile.pdf");

            var bodyBuilder = new BodyBuilder();
            bodyBuilder.TextBody = "Testing the body message";

            //You must to inform the mime-type of the attachment and his name
            bodyBuilder.Attachments.Add("AnyAttachment.pdf", fileBytes, new ContentType("application", "pdf"));
            mimeMessage.Body = bodyBuilder.ToMessageBody();

            //Map MimeMessage to MemoryStream, that is what SenRawEmailRequest accepts
            var rawMessage = new MemoryStream();
            mimeMessage.WriteTo(rawMessage);

            client.SendRawEmail(new SendRawEmailRequest(new RawMessage(rawMessage)));
            Console.WriteLine("Email Sended");

            Console.ReadKey();
        }
示例#5
0
        public static void SendVerificationEmail(string emailaddress, string validation_guid)
        {
            const string VERIFICATION_DOMAIN = "https://nzixo03fx1.execute-api.us-west-2.amazonaws.com/prod/emailvalidation?verificationstring="; //TODO: Move this to our domain name prior to launch
            const string FROM = "*****@*****.**"; //TODO: Change to real domain name
            const string SUBJECT = "Please verify your email address";
            string TO = emailaddress;
            string mBase64EncodedGuid = Convert.ToBase64String(Encoding.UTF8.GetBytes(emailaddress + ":" + validation_guid));

            var message = new MimeMessage();
            message.From.Add(new MailboxAddress("GEM CARRY EMAIL VERIFICATION", FROM));
            message.To.Add(new MailboxAddress("New Gamer", TO));
            message.Subject = SUBJECT;

            var builder = new BodyBuilder();
            builder.TextBody = string.Format("To activate your account, please click the following link to verifiy your email address {0}{1}", VERIFICATION_DOMAIN, mBase64EncodedGuid);
            builder.HtmlBody = string.Format("To activate your account, please click <a href={0}{1}> here</a> to verify your email address.",VERIFICATION_DOMAIN,mBase64EncodedGuid);

            message.Body = builder.ToMessageBody();

            var stream = new MemoryStream();
            message.WriteTo(stream);

            try
            {
                AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient();
                var request = new SendRawEmailRequest { RawMessage = new RawMessage { Data = stream } };
                client.SendRawEmail(request);
            #if DEBUG
                logger.WriteLog(GameLogger.LogLevel.Debug, string.Format("Generating Validation Email for {0}.", emailaddress));
            #endif // DEBUG

            }
            catch (Exception ex)
            {
                logger.WriteLog(GameLogger.LogLevel.Error, ex.Message.ToString());
            }
        }