Configuration for accessing Amazon SimpleEmailService service
Наследование: Amazon.Runtime.ClientConfig
Пример #1
1
 /// <summary>
 /// Create a client for the Amazon SimpleEmailService Service with the credentials loaded from the application's
 /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
 /// 
 /// Example App.config with credentials set. 
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSAccessKey" value="********************"/&gt;
 ///         &lt;add key="AWSSecretKey" value="****************************************"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 /// </summary>
 /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc</param>
 /// <returns>An Amazon SimpleEmailService client</returns>
 public static AmazonSimpleEmailService CreateAmazonSimpleEmailServiceClient(AmazonSimpleEmailServiceConfig config)
 {
     return new AmazonSimpleEmailServiceClient(config);
 }
Пример #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>";
        }
    }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AmazonSimpleEmailServiceConfig amConfig = new AmazonSimpleEmailServiceConfig();
            amConfig.UseSecureStringForAwsSecretKey = false;
            AmazonSimpleEmailServiceClient amzClient = new AmazonSimpleEmailServiceClient(ConfigurationManager.AppSettings["AWSAccessKey"].ToString(), ConfigurationManager.AppSettings["AWSSecretKey"].ToString(),amConfig);
            ArrayList to = new ArrayList();
            //ADD AS TO 50 emails per one sending method//////////////////////
            //to.Add("*****@*****.**");
            //to.Add("*****@*****.**");
            to.Add("*****@*****.**");
            to.Add("*****@*****.**");
            to.Add("*****@*****.**");
            to.Add("*****@*****.**");
            to.Add("*****@*****.**");
            to.Add("*****@*****.**");

            Destination dest = new Destination();
            dest.WithToAddresses((string[])to.ToArray(typeof(string)));

            //dest.WithToAddresses((string[])to.ToArray(typeof(string)));
            string body = "INSERT HTML BODY HERE";
            string subject = "INSERT EMAIL SUBJECT HERE";
            Body bdy = new Body();
            bdy.Html = new Amazon.SimpleEmail.Model.Content(body);
            Amazon.SimpleEmail.Model.Content title = new Amazon.SimpleEmail.Model.Content(subject);
            Message message = new Message(title, bdy);

               //VerifyEmailAddressRequest veaRequest = new VerifyEmailAddressRequest();
               // veaRequest.EmailAddress = "*****@*****.**";
               // VerifyEmailAddressResponse veaResponse = amzClient.VerifyEmailAddress(veaRequest);

            SendEmailRequest ser = new SendEmailRequest("*****@*****.**", dest, message);

            ser.WithReturnPath("*****@*****.**");
            SendEmailResponse seResponse = amzClient.SendEmail(ser);
            SendEmailResult seResult = seResponse.SendEmailResult;

            //GetSendStatisticsRequest request=new GetSendStatisticsRequest();

            //GetSendStatisticsResponse obj = amzClient.GetSendStatistics(request);

            //List<SendDataPoint> sdata = new List<SendDataPoint>();
            //sdata=obj.GetSendStatisticsResult.SendDataPoints;

            //Int64 sentCount = 0,BounceCount=0,DeleveryAttempts=0;

            //for (int i = 0; i < sdata.Count; i++)
            //{
            //    BounceCount = BounceCount +sdata[i].Bounces;
            //    DeleveryAttempts = DeleveryAttempts + sdata[i].DeliveryAttempts;
            //}
            //sentCount = DeleveryAttempts - BounceCount;
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AmazonSimpleEmailServiceConfig amConfig = new AmazonSimpleEmailServiceConfig();
            amConfig.UseSecureStringForAwsSecretKey = false;
            AmazonSimpleEmailServiceClient amzClient = new AmazonSimpleEmailServiceClient(ConfigurationManager.AppSettings["AWSAccessKey"].ToString(), ConfigurationManager.AppSettings["AWSSecretKey"].ToString(), amConfig);
            ArrayList to = new ArrayList();
            to.Add("*****@*****.**");
            //to.Add("*****@*****.**");
            for (int i = 0; i < to.Count; i++)
            {
                Destination dest = new Destination();
                dest.WithToAddresses(to[i].ToString());
                string body = "Hello this is testing AWS";
                string subject = "Test AWS";
                Body bdy = new Body();
                bdy.Html = new Amazon.SimpleEmail.Model.Content(body);
                Amazon.SimpleEmail.Model.Content title = new Amazon.SimpleEmail.Model.Content(subject);
                Message message = new Message(title, bdy);
                SendEmailRequest ser = new SendEmailRequest("*****@*****.**", dest, message);
                ser.WithReturnPath("*****@*****.**");
                SendEmailResponse seResponse = amzClient.SendEmail(ser);
                SendEmailResult seResult = seResponse.SendEmailResult;

            }

            //GetSendStatisticsRequest request = new GetSendStatisticsRequest();
            //GetSendStatisticsResponse obj = amzClient.GetSendStatistics(request);
            //List<SendDataPoint> sdata = new List<SendDataPoint>();
            //sdata = obj.GetSendStatisticsResult.SendDataPoints;
            //Int64 sentCount = 0, BounceCount = 0, DeleveryAttempts = 0;
            //for (int i = 0; i < sdata.Count; i++)
            //{
            //    BounceCount = BounceCount + sdata[i].Bounces;
            //    DeleveryAttempts = DeleveryAttempts + sdata[i].DeliveryAttempts;
            //}
            //sentCount = DeleveryAttempts - BounceCount;
        }
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with AWS Access Key ID, AWS Secret Key and an
 /// AmazonSimpleEmailServiceClient Configuration object. 
 /// </summary>
 /// <param name="awsAccessKeyId">AWS Access Key ID</param>
 /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
 /// <param name="awsSessionToken">AWS Session Token</param>
 /// <param name="clientConfig">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonSimpleEmailServiceConfig clientConfig)
     : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig)
 {
 }
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with AWS Credentials and an
 /// AmazonSimpleEmailServiceClient Configuration object.
 /// </summary>
 /// <param name="credentials">AWS Credentials</param>
 /// <param name="clientConfig">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(AWSCredentials credentials, AmazonSimpleEmailServiceConfig clientConfig)
     : base(credentials, clientConfig)
 {
 }
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with the credentials loaded from the application's
 /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
 /// 
 /// Example App.config with credentials set. 
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSProfileName" value="AWS Default"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 ///
 /// </summary>
 /// <param name="config">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(AmazonSimpleEmailServiceConfig config)
     : base(FallbackCredentialsFactory.GetCredentials(), config) { }
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with AWS Credentials and an
 /// AmazonSimpleEmailServiceClient Configuration object.
 /// </summary>
 /// <param name="credentials">AWS Credentials</param>
 /// <param name="clientConfig">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(AWSCredentials credentials, AmazonSimpleEmailServiceConfig clientConfig)
     : base(credentials, clientConfig, AuthenticationTypes.User | AuthenticationTypes.Session)
 {
 }
        public bool SendEmail()
        {
            //INITIALIZE AWS CLIENT//
            AmazonSimpleEmailServiceConfig amConfig = new AmazonSimpleEmailServiceConfig();
            //amConfig.UseSecureStringForAwsSecretKey = false;
            AmazonSimpleEmailServiceClient amzClient = new AmazonSimpleEmailServiceClient(
              AppSettingHelper.GetAmazonAccessKey(),AppSettingHelper.GetAmazonSecretKey(),//ConfigurationManager.AppSettings["AWSAccessKey"].ToString(),
               RegionEndpoint.USEast1);// ConfigurationManager.AppSettings["AWSSecretKey"].ToString(), amConfig);

            //ArrayList that holds To Emails. It can hold 1 Email to any
            //number of emails in case what to send same message to many users.
            var to = new List<string>();
            to.Add("*****@*****.**");

            //Create Your Bcc Addresses as well as Message Body and Subject
            Destination dest = new Destination();
            dest.BccAddresses.Add("*****@*****.**");
            //string body = Body;
            string subject = "Subject : " + "Demo Mail";
            Body bdy = new Body();
            bdy.Html = new Amazon.SimpleEmail.Model.Content("Test Mail");
            Amazon.SimpleEmail.Model.Content title = new Amazon.SimpleEmail.Model.Content(subject);
            Message message = new Message(title, bdy);

            //Create A Request to send Email to this ArrayList with this body and subject
            try
            {
                SendEmailRequest ser = new SendEmailRequest("*****@*****.**", dest, message);
                SendEmailResponse seResponse = amzClient.SendEmail(ser);
               // SendEmailResult seResult = seResponse.SendEmailResult;
            }
            catch (Exception ex)
            {

            }

            return true;
        }
Пример #10
0
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with AWS Credentials and an
 /// AmazonSimpleEmailServiceClient Configuration object.
 /// </summary>
 /// <param name="credentials">AWS Credentials</param>
 /// <param name="clientConfig">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(AWSCredentials credentials, AmazonSimpleEmailServiceConfig clientConfig)
     : base(credentials, clientConfig)
 {
 }
Пример #11
0
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with AWS Access Key ID, AWS Secret Key and an
 /// AmazonSimpleEmailServiceClient Configuration object.
 /// </summary>
 /// <param name="awsAccessKeyId">AWS Access Key ID</param>
 /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
 /// <param name="awsSessionToken">AWS Session Token</param>
 /// <param name="clientConfig">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonSimpleEmailServiceConfig clientConfig)
     : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig)
 {
 }
Пример #12
0
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with the credentials defined in the App.config.
 ///
 /// Example App.config with credentials set.
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSAccessKey" value="********************"/&gt;
 ///         &lt;add key="AWSSecretKey" value="****************************************"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 ///
 /// </summary>
 /// <param name="config">The AmazonSimpleEmailService Configuration Object</param>
 public AmazonSimpleEmailServiceClient(AmazonSimpleEmailServiceConfig config)
     : base(new EnvironmentAWSCredentials(), config, true, AuthenticationTypes.User)
 {
 }
Пример #13
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // 尝试注册用户
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    //Send email by amazon ses
                    string accessKey = "AKIAIO4BEQ2UGFAMHRFQ";
                    string secretAccessKey = "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";
                    AmazonSimpleEmailServiceConfig amazonConfiguration = new AmazonSimpleEmailServiceConfig();
                    AmazonSimpleEmailServiceClient clientMail = new AmazonSimpleEmailServiceClient(accessKey, secretAccessKey, amazonConfiguration);
                    Destination destination = new Destination();
                    destination.ToAddresses.Add(model.Email);
                    Body body = new Body() { Html = new Content("Welcome to AIRPDF "+"Your account is: "+model.UserName+" Your password is: "+model.ConfirmPassword) };
                    Content subject = new Content("Welcome to AIRPDF!");
                    Message message = new Message(subject, body);
                    SendEmailRequest sendEmailRequest = new SendEmailRequest("*****@*****.**", destination, message);
                    clientMail.SendEmail(sendEmailRequest);

                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "pdf");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return View(model);
        }
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with the credentials defined in the App.config.
 /// 
 /// Example App.config with credentials set. 
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSAccessKey" value="********************"/&gt;
 ///         &lt;add key="AWSSecretKey" value="****************************************"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 ///
 /// </summary>
 /// <param name="config">The AmazonSimpleEmailService Configuration Object</param>
 public AmazonSimpleEmailServiceClient(AmazonSimpleEmailServiceConfig config)
     : base(new EnvironmentAWSCredentials(), config, true, AuthenticationTypes.User)
 {
 }
Пример #15
0
 /// <summary>
 /// Create a client for the Amazon SimpleEmailService Service with the specified configuration
 /// </summary>
 /// <param name="awsAccessKey">The AWS Access Key associated with the account</param>
 /// <param name="awsSecretAccessKey">The AWS Secret Access Key associated with the account</param>
 /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc
 /// </param>
 /// <returns>An Amazon SimpleEmailService client</returns>
 /// <remarks>
 /// </remarks>
 public static IAmazonSimpleEmailService CreateAmazonSimpleEmailServiceClient(
     string awsAccessKey,
     string awsSecretAccessKey, AmazonSimpleEmailServiceConfig config
     )
 {
     return new AmazonSimpleEmailServiceClient(awsAccessKey, awsSecretAccessKey, config);
 }
Пример #16
0
 /// <summary>
 /// Create a client for the Amazon SimpleEmailService Service with AWSCredentials and an AmazonSimpleEmailService Configuration object.
 /// </summary>
 /// <param name="credentials">AWS Credentials</param>
 /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc</param>
 /// <returns>An Amazon SimpleEmailService client</returns>
 /// <remarks>
 /// </remarks>
 public static IAmazonSimpleEmailService CreateAmazonSimpleEmailServiceClient(AWSCredentials credentials, AmazonSimpleEmailServiceConfig config)
 {
     return new AmazonSimpleEmailServiceClient(credentials, config);
 }
Пример #17
0
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with AWS Access Key ID, AWS Secret Key and an
 /// AmazonSimpleEmailServiceClient Configuration object. If the config object's
 /// UseSecureStringForAwsSecretKey is false, the AWS Secret Key
 /// is stored as a clear-text string. Please use this option only
 /// if the application environment doesn't allow the use of SecureStrings.
 /// </summary>
 /// <param name="awsAccessKeyId">AWS Access Key ID</param>
 /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
 /// <param name="awsSessionToken">AWS Session Token</param>
 /// <param name="clientConfig">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonSimpleEmailServiceConfig clientConfig)
     : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig, AuthenticationTypes.User | AuthenticationTypes.Session)
 {
 }
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with the credentials loaded from the application's
 /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance.
 /// 
 /// Example App.config with credentials set. 
 /// <code>
 /// &lt;?xml version="1.0" encoding="utf-8" ?&gt;
 /// &lt;configuration&gt;
 ///     &lt;appSettings&gt;
 ///         &lt;add key="AWSAccessKey" value="********************"/&gt;
 ///         &lt;add key="AWSSecretKey" value="****************************************"/&gt;
 ///     &lt;/appSettings&gt;
 /// &lt;/configuration&gt;
 /// </code>
 ///
 /// </summary>
 /// <param name="config">The AmazonSimpleEmailService Configuration Object</param>
 public AmazonSimpleEmailServiceClient(AmazonSimpleEmailServiceConfig config)
     : base(FallbackCredentialsFactory.GetCredentials(), config, AuthenticationTypes.User | AuthenticationTypes.Session) { }
Пример #19
0
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with AWS Credentials and an
 /// AmazonSimpleEmailServiceClient Configuration object.
 /// </summary>
 /// <param name="credentials">AWS Credentials</param>
 /// <param name="clientConfig">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(AWSCredentials credentials, AmazonSimpleEmailServiceConfig clientConfig)
     : base(credentials, clientConfig, AuthenticationTypes.User | AuthenticationTypes.Session)
 {
 }
 /// <summary>
 /// Constructs AmazonSimpleEmailServiceClient with AWS Access Key ID, AWS Secret Key and an
 /// AmazonSimpleEmailServiceClient Configuration object.
 /// </summary>
 /// <param name="awsAccessKeyId">AWS Access Key ID</param>
 /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
 /// <param name="awsSessionToken">AWS Session Token</param>
 /// <param name="clientConfig">The AmazonSimpleEmailServiceClient Configuration Object</param>
 public AmazonSimpleEmailServiceClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonSimpleEmailServiceConfig clientConfig)
     : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig, AuthenticationTypes.User | AuthenticationTypes.Session)
 {
 }
Пример #21
0
        private AmazonSimpleEmailService CreateAmazonSes(Ec2Key ec2Key)
        {
            var sesConfig = new AmazonSimpleEmailServiceConfig();
            AmazonSimpleEmailService ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(ec2Key.AwsAccessKey, ec2Key.AwsSecretKey, sesConfig);

            return ses;
        }