当前位置: 首页>>代码示例>>C#>>正文


C# Model.SendEmailRequest类代码示例

本文整理汇总了C#中Amazon.SimpleEmail.Model.SendEmailRequest的典型用法代码示例。如果您正苦于以下问题:C# SendEmailRequest类的具体用法?C# SendEmailRequest怎么用?C# SendEmailRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SendEmailRequest类属于Amazon.SimpleEmail.Model命名空间,在下文中一共展示了SendEmailRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnSend_Click

        protected void btnSend_Click(object sender, EventArgs e)
        {
            string fromAddress = "[email protected]";  // Replace with your "From" address. This address must be verified.
            string recipientAddress = "[email protected]"; // Replace with a "To" address. If your account is still in the
            string subject = "Test sending email using AWS SDK with C#";
            string body = "This is the email content!";

            AWSCredentials credentials = new BasicAWSCredentials("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY");

            using (var client = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(credentials, RegionEndpoint.USEast1))
            {
                var request = new SendEmailRequest
                {
                    Source = fromAddress,
                    Destination = new Destination { ToAddresses = new List<string> { recipientAddress } },
                    Message = new Message
                    {
                        Subject = new Amazon.SimpleEmail.Model.Content(subject),
                        Body = new Body { Text = new Amazon.SimpleEmail.Model.Content(body) }
                    }
                };

                try
                {
                    // Send the email.
                    var response = client.SendEmail(request);
                    Response.Write("Email sent!");
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
        }
开发者ID:chienvh,项目名称:AmazonSES,代码行数:34,代码来源:UsingAWS_SDK.aspx.cs

示例2: SendEmails

        public void SendEmails(AmazonSimpleEmailServiceClient aClient)
        {
            IEnumerable<EmailJob> myEmailsToSendOut = theEmailRepo.GetEmailJobsToBeSent();
            if (myEmailsToSendOut.Count<EmailJob>() != 0) {
                ConsoleMessageWithDate("Have to send emails: " + myEmailsToSendOut.Count<EmailJob>());
                foreach (EmailJob myEmailJob in myEmailsToSendOut) {
                    SendEmailRequest myRequest = new SendEmailRequest();

                    List<string> mySendTo = new List<string>();
                    mySendTo.Add(myEmailJob.ToEmail);

                    Content mySubject = new Content(myEmailJob.Subject);
                    Body myBody = new Body();
                    myBody.Html = new Content(myEmailJob.Body);

                    myRequest.Destination = new Destination(mySendTo);
                    myRequest.Message = new Message(mySubject, myBody);
                    myRequest.Source = myEmailJob.FromEmail;

                    //Change flag with the send in between so we can track if shit happened
                    theEmailRepo.MarkEmailPresentToTrue(myEmailJob.Id);
                    aClient.SendEmail(myRequest);
                    theEmailRepo.MarkEmailPostsentToTrue(myEmailJob.Id);

                    ConsoleMessageWithDate("A " + myEmailJob.EmailDescription + " has been sent to " + myEmailJob.ToEmail + " from " + myEmailJob.FromEmail);
                }
            } else {
                ConsoleMessageWithDate("No emails required to be sent out");
            }
        }
开发者ID:henryksarat,项目名称:Have-A-Voice,代码行数:30,代码来源:EmailService.cs

示例3: SESSendEmail

    public static void SESSendEmail()
    {
      #region SESSendEmail
      var sesClient = new AmazonSimpleEmailServiceClient();           
      
      var dest = new Destination
      {
        ToAddresses = new List<string>() { "[email protected]" },
        CcAddresses = new List<string>() { "[email protected]" }
      };

      var from = "[email protected]";
      var subject = new Content("You're invited to the meeting");
      var body = new Body(new Content("Please join us Monday at 7:00 PM."));
      var msg = new Message(subject, body);

      var request = new SendEmailRequest
      {
        Destination = dest,
        Message = msg, 
        Source = from
      };

      sesClient.SendEmail(request);
      #endregion
    }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:26,代码来源:SESSamples.cs

示例4: Main

        static void Main(string[] args)
        {
            if (CheckRequiredFields())
            {
                using (var client = new AmazonSimpleEmailServiceClient(RegionEndpoint.USEast1))
                {
                    var sendRequest = new SendEmailRequest
                                        {
                                            Source = senderAddress,
                                            Destination = new Destination { ToAddresses = new List<string> { receiverAddress } },
                                            Message = new Message
                                            {
                                                Subject = new Content("Sample Mail using SES"),
                                                Body = new Body { Text = new Content("Sample message content.") }
                                            }
                                        };
                    try
                    {
                        Console.WriteLine("Sending email using AWS SES...");
                        var response = client.SendEmail(sendRequest);
                        Console.WriteLine("The email was sent successfully.");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("The email was not sent.");
                        Console.WriteLine("Error message: " + ex.Message);

                    }
                }
            }

            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
开发者ID:awslabs,项目名称:aws-sdk-net-samples,代码行数:34,代码来源:Program.cs

示例5: SendEmail

        public Task<bool> SendEmail(string to, string subject, string htmlBody)
        {
            if (string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(htmlBody) || !to.IsEmail()) return Task.FromResult(false);

            var destination = new Destination { ToAddresses = new List<string> { to } };

            var contentSubject = new Content { Charset = Encoding.UTF8.EncodingName, Data = subject };
            var contentBody = new Content { Charset = Encoding.UTF8.EncodingName, Data = htmlBody };
            var body = new Body { Html = contentBody };

            var message = new Message { Body = body, Subject = contentSubject };

            var request = new SendEmailRequest
            {
                Source = FROM_EMAIL,
                Destination = destination,
                Message = message
            };

            var client = new AmazonSimpleEmailServiceClient();

            try
            {
                client.SendEmail(request);
            }
            catch (Exception ex)
            {
               return Task.FromResult(false);
            }

            return Task.FromResult(true);
        }
开发者ID:rmzsmr,项目名称:set-basic-aspnet-mvc,代码行数:32,代码来源:MessageService.cs

示例6: Send

        public void Send(string name, string replyTo, string messageBody)
        {
            var destination = new Destination()
            {
                ToAddresses = new List<string>() { TO }
            };

            var subject = new Content(SUBJECT);

            var body = new Body()
            {
                Html = new Content(string.Format(BODY, name, messageBody))
            };

            var message = new Message(subject, body);

            var request = new SendEmailRequest(FROM, destination, message);

            request.ReplyToAddresses = new List<string> { replyTo };

            var region = Amazon.RegionEndpoint.USEast1;

            using (var client = new AmazonSimpleEmailServiceClient(region))
            {
                try
                {
                    client.SendEmail(request);
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
开发者ID:Aramai,项目名称:domain-home,代码行数:34,代码来源:SendMail.asmx.cs

示例7: SendEmailWithAmazone

        public static bool SendEmailWithAmazone(string FROM, string TO, string SUBJECT, string BODY, string AWSAccessKey, string AWSSecrectKey, string NameSender)
        {
            string Name = NameSender;
            Destination destination = new Destination().WithToAddresses(new List<string>() { TO });
            // Create the subject and body of the message.
            Amazon.SimpleEmail.Model.Content subject = new Amazon.SimpleEmail.Model.Content().WithData(SUBJECT);
            Amazon.SimpleEmail.Model.Content textBody = new Amazon.SimpleEmail.Model.Content().WithData(BODY);
            Body body = new Body().WithHtml(textBody);

            // Create a message with the specified subject and body.
            Message message = new Message().WithSubject(subject).WithBody(body);

            string Fr = String.Format("{0}<{1}>", Name, FROM);
            SendEmailRequest request = new SendEmailRequest().WithSource(Fr).WithDestination(destination).WithMessage(message);
            using (AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(AWSAccessKey, AWSSecrectKey))
            {
                // Send the email.
                try
                {
                    client.SendEmail(request);
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
开发者ID:phonglam29305,项目名称:FAMail,代码行数:28,代码来源:ProcessSendEmail.cs

示例8: SendEmail

        //From E-mail address must be verified through Amazon
        /// <param name="AWSAccessKey">public key associated with our Amazon Account</param>
        /// <param name="AWSSecretKey">private key associated with our Amazon Account</param>
        /// <param name="ToEmail">Who do you want to send the E-mail to, seperate multiple addresses with a comma</param>
        /// <param name="FromEmail">Who is the e-mail from, this must be a verified e-mail address through Amazon</param>
        /// <param name="Subject">Subject of e-mail</param>
        /// <param name="Content">Text for e-mail</param>
        public void SendEmail(string AWSAccessKey, string AWSSecretKey, string ToEmail, string FromEmail, string Subject, string Content)
        {
            Amazon.SimpleEmail.AmazonSimpleEmailServiceClient client = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient(AWSAccessKey, AWSSecretKey);

            SendEmailRequest em = new SendEmailRequest()
                            .WithDestination(new Destination() { BccAddresses = new List<String>() { ToEmail } })
                            .WithSource(FromEmail)
                            .WithMessage(new Message(new Content(Subject), new Body().WithText(new Content(Content))));
            SendEmailResponse response = client.SendEmail(em);
        }
开发者ID:KCL5South,项目名称:AmazonEMail,代码行数:17,代码来源:CloudMail.cs

示例9: Page_Load

        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("[email protected]");
            //to.Add("[email protected]");
            to.Add("[email protected]");
            to.Add("[email protected]");
            to.Add("[email protected]");
            to.Add("[email protected]");
            to.Add("[email protected]");
            to.Add("[email protected]");

            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 = "[email protected]";
               // VerifyEmailAddressResponse veaResponse = amzClient.VerifyEmailAddress(veaRequest);

            SendEmailRequest ser = new SendEmailRequest("[email protected]", dest, message);

            ser.WithReturnPath("[email protected]");
            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;
        }
开发者ID:shekar348,项目名称:1PointOne,代码行数:53,代码来源:AWS2.aspx.cs

示例10: SendEmail

 public void SendEmail(string to, string subject, string bodyText, string bodyHtml)
 {
     using (var client = new AmazonSimpleEmailServiceClient(RegionEndpoint.EUWest1))
     {
         var content = new Content(subject);
         var body = new Body{Html = new Content(bodyHtml), Text = new Content(bodyText)};
         var message = new Message(content, body);
         var destination = new Destination(new List<string> {to});
         var sendEmailRequest = new SendEmailRequest(FromEmail, destination, message);
         client.SendEmail(sendEmailRequest);
     }
 }
开发者ID:moorcroftlad,项目名称:StockSharer,代码行数:12,代码来源:SesEmailSender.cs

示例11: Send

        public async Task Send(Indulgence indulgence, string indulgenceFilePath)
        {
            service =
                new AmazonSimpleEmailServiceClient(
                    ConfigurationManager.AppSettings["awsAccessKeyId"],
                    ConfigurationManager.AppSettings["awsAccessSecret"]);

            SendEmailRequest request = new SendEmailRequest();
            request.Destination = BuildDestination();
            request.Message=BuildMessage(indulgence);
            request.Source="[email protected]";

            var response = service.SendEmail(request);
        }
开发者ID:andrewmyhre,项目名称:IndulgeMe,代码行数:14,代码来源:AmazonSESIndulgenceEmailer.cs

示例12: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            string AccessKey= System.Configuration.ConfigurationManager.AppSettings["AccessKey"];
            string SecrectKey = System.Configuration.ConfigurationManager.AppSettings["SecrectKey"];
            Amazon.SimpleEmail.AmazonSimpleEmailServiceClient mailClient = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient(AccessKey,SecrectKey);
            //var obj = mailClient.GetSendQuota();
            SendEmailRequest request = new SendEmailRequest();
            List<string> toaddress = new List<string>();
            toaddress.Add("[email protected]");
            Destination des = new Destination(toaddress);
            request.Destination = des;
            request.Source = "[email protected]";
            Amazon.SimpleEmail.Model.Message mes = new Amazon.SimpleEmail.Model.Message();
            mes.Body = new Body(new Content( @"Hiện tại, Windows Phone mới hỗ trợ đến màn hình full HD, do đó để tương thích với màn hình 2K, hệ điều hành chắc chắn phải có bản cập nhật mới. Mặt khác, vi xử lý Snapdragon 805 của Qualcomm được biết sẽ phát hành đại trà vào nửa sau năm nay, nên thời điểm xuất hiện Lumia 1820 dùng vi xử lý này tại MWC 2014 vào tháng Hai sẽ là dấu hỏi lớn.

            Microsoft đã từng nói hãng đã chi tới 2,6 tỉ USD để phát triển cho hệ điều hành Windows Phone. Và năm nay, Microsoft đang có kế hoạch lớn dành cho Windows Phone lẫn Nokia. Do đó, chúng ta hãy cứ hy vọng Lumia 1525 và Lumia 1820 sẽ là bom tấn smartphone được kích hoạt trong 2014 này."));
            mes.Subject = new Content("Test send via amazon");

            request.Message = mes;

            SendEmailResponse response = mailClient.SendEmail(request);
            var messageId = response.SendEmailResult.MessageId;
            /*GetIdentityNotificationAttributesRequest notifyRequest = new GetIdentityNotificationAttributesRequest();
            List<string> iden = new List<string>();
            iden.Add("[email protected]"); //iden.Add(response.ResponseMetadata.RequestId);
            notifyRequest.Identities = iden;
            var notify = mailClient.GetIdentityNotificationAttributes(notifyRequest);
            //MessageBox.Show(notify.GetIdentityNotificationAttributesResult.NotificationAttributes["Bounces"].BounceTopic);

            var temp = mailClient.GetSendStatistics();
            MessageBox.Show("Total: "+temp.GetSendStatisticsResult.SendDataPoints.Count+"\nDeliveryAttempts: "+temp.GetSendStatisticsResult.SendDataPoints[265].DeliveryAttempts+"\n"
                + "Complaints: " + temp.GetSendStatisticsResult.SendDataPoints[265].Complaints + "\n"
                + "Bounces: " + temp.GetSendStatisticsResult.SendDataPoints[265].Bounces + "\n"
                + "Rejects: " + temp.GetSendStatisticsResult.SendDataPoints[265].Rejects + "\n");
               // MessageBox.Show("Max24HourSend:" + obj.GetSendQuotaResult.Max24HourSend + "\nMaxSendRate:" + obj.GetSendQuotaResult.MaxSendRate + "\nSentLast24Hours:" + obj.GetSendQuotaResult.SentLast24Hours);

            Amazon.SimpleNotificationService.Model.GetEndpointAttributesRequest endpointRequest = new Amazon.SimpleNotificationService.Model.GetEndpointAttributesRequest();
            Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient notifyClient = new Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient();
            //string result = notifyClient.GetEndpointAttributes(notify).GetEndpointAttributesResult.ToXML();
            //MessageBox.Show(result);
            */
            Amazon.SQS.AmazonSQSClient client = new Amazon.SQS.AmazonSQSClient(AccessKey, SecrectKey);
            Amazon.SQS.Model.ReceiveMessageRequest SQSrequest = new Amazon.SQS.Model.ReceiveMessageRequest();
            SQSrequest.MaxNumberOfMessages = 10;
            SQSrequest.QueueUrl = "https://sqs.us-east-1.amazonaws.com/063719400628/bounce-queue";
            AmazonQueues.ProcessQueuedBounce(client.ReceiveMessage(SQSrequest));
        }
开发者ID:phonglam29305,项目名称:FAMail,代码行数:47,代码来源:frmMail.cs

示例13: SendMail

 /// <summary>
 /// The send mail.
 /// </summary>
 /// <param name="from">
 /// The from.
 /// </param>
 /// <param name="to">
 /// The to.
 /// </param>
 /// <param name="subject">
 /// The subject.
 /// </param>
 /// <param name="body">
 /// The body.
 /// </param>
 public void SendMail(string @from, string to, string subject, string body)
 {
     using (var client = Amazon.AWSClientFactory.CreateAmazonSimpleEmailServiceClient(this.credentials))
     {
         var request = new SendEmailRequest();
         var destination = new Destination(to.Split(';', ',').ToList());
         request.WithDestination(destination);
         request.WithSource(@from);
         var message = new Message();
         message.WithSubject(new Content(subject));
         var html = new Body { Html = new Content(body) };
         message.WithBody(html);
         request.WithMessage(message);
         request.WithReturnPath("[email protected]");
         client.SendEmail(request);
     }
 }
开发者ID:Naviam,项目名称:Shop-Any-Ware,代码行数:32,代码来源:AmazonSimpleEmailService.cs

示例14: SendMail

        /// <summary>
        ///     Sends an email with opt out option
        /// </summary>
        /// <param name="fromEmail"></param>
        /// <param name="toEmail"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public bool SendMail(string fromEmail, string toEmail, string subject, string body)
        {
            if (string.IsNullOrEmpty(toEmail) ||
                string.IsNullOrEmpty(fromEmail) ||
                string.IsNullOrEmpty(subject) ||
                string.IsNullOrEmpty(body)) return false;

            try
            {
                toEmail = toEmail.Trim();
                fromEmail = fromEmail.Trim();

                var amzClient = new AmazonSimpleEmailServiceClient(
                    AmazonCloudConfigs.AmazonAccessKey, AmazonCloudConfigs.AmazonSecretKey, RegionEndpoint.USEast1);
                var dest = new Destination();
                dest.ToAddresses.Add(toEmail);

                body =
                    body +
                    Environment.NewLine +
                    Environment.NewLine +
                    Environment.NewLine +
                    Environment.NewLine +
                    Environment.NewLine +
                    "----------------------------" +
                    Environment.NewLine +
                    "Unsubscribe From Email: " + // TODO: LOCALIZE
                    Environment.NewLine +
                    GeneralConfigs.EmailSettingsURL +
                    Environment.NewLine;

                var bdy = new Body {Text = new Content(body)};
                var title = new Content(subject);
                var message = new Message(title, bdy);
                fromEmail = string.Format("{0} <{1}>", GeneralConfigs.SiteName, fromEmail);
                var ser = new SendEmailRequest(fromEmail, dest, message);

                var response = amzClient.SendEmail(ser);

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
开发者ID:dasklub,项目名称:kommunity,代码行数:54,代码来源:MailService.cs

示例15: SendMail

        public void SendMail(string to, string subject, string body)
        {
            //smtp would've been quicker but the SSL that .NET uses isn't the same as AWS
            using(var sesClient  = AWSClientFactory.CreateAmazonSimpleEmailServiceClient() )
            {
                string sesFromEmail = ConfigurationManager.AppSettings[Constants.SES_FROM_EMAIL];

                var sendEmailRequest = new SendEmailRequest()
                    .WithDestination(new Destination().WithToAddresses(to))
                    .WithSource(sesFromEmail) // The sender's email address.
                    .WithReturnPath(sesFromEmail)// The email address to which bounce notifications are to be forwarded.
                    .WithMessage(new Message()
                                 	.WithBody(new Body().WithHtml(new Content(body).WithCharset("UTF-8")))
                                 	.WithSubject(new Content(subject).WithCharset("UTF-8")));

                var response = sesClient.SendEmail(sendEmailRequest);
            }
        }
开发者ID:scottccoates,项目名称:CliqFlip,代码行数:18,代码来源:SESEmailService.cs


注:本文中的Amazon.SimpleEmail.Model.SendEmailRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。