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


C# SendEmailRequest.WithMessage方法代码示例

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


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

示例1: 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

示例2: SendEmail

        public void SendEmail()
        {
            var client = Amazon.AWSClientFactory.CreateAmazonSimpleEmailServiceClient(EmailProcessingConfigurationManager.Section.Amazon.Key, EmailProcessingConfigurationManager.Section.Amazon.Secret);

            Destination destination = new Destination();
            destination.WithToAddresses("[email protected]");

            Content subject = new Content();
            subject.WithCharset("UTF-8");
            subject.WithData("subject");

            Content html = new Content();
            html.WithCharset("UTF-8");
            html.WithData(@"<p>Hi {DonorName},</p>
            <p>Thank you for making a donation to {CharityName}. In return for your goodwill we have created your very own papal indulgence. You are free to download it, print it and lord your piousness over your friends!</p>
            <p><a href=""{ServerAuthority}/content/{IndulgenceId}/indulgence.pdf""><img src=""/content/indulgences/{IndulgenceId}/indulgence_25.png"" /></a></p>
            <p><a href=""{ServerAuthority}/content/{IndulgenceId}/indulgence.pdf"">Click here to download your indulgence</a></p>
            <p>Regards,</p>
            <p>Andrew</p>
            <p>IndulgeMe.cc</p>");

            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);

            SendEmailRequest request = new SendEmailRequest();
            request.WithDestination(destination);
            request.WithMessage(message);
            request.WithSource("[email protected]");

            client.SendEmail(request);
        }
开发者ID:andrewmyhre,项目名称:IndulgeMe,代码行数:40,代码来源:AmazonServiceTests.cs

示例3: StartMta

        private void StartMta()
        {
            // Check if there is already a thread running, if not start one to start proccessing the queue
            if (_mta != null && _mta.IsAlive)
                return;

            _mta = new Thread(() =>
            {
                // Create an amazon ses client
                // Retreive send rate
                if (_ses == null)
                {
                    _ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(AwsAccessKey, AwsSecretKey);

                    // Try and get the sending quota from amazon
                    // This will fail if invalid credentials are provided
                    try
                    {
                        _quota = _ses.GetSendQuota(new GetSendQuotaRequest());
                    }
                    catch (Exception ex)
                    {
                        InternalLogger.Fatal("Error retreiving send quota from amazone: {0}", ex.Message);
                        return;
                    }

                    InternalLogger.Info("Amazon SES quota loaded, max send rate: {0} per second, 24 hour quota: {1}, sent in the last 24 hours: {2}", _quota.GetSendQuotaResult.MaxSendRate, _quota.GetSendQuotaResult.Max24HourSend, _quota.GetSendQuotaResult.SentLast24Hours);
                }

                while (true)
                {
                    // Try and get a message from the queue
                    // will fail if there are no messages to send
                    Message message = null;
                    try
                    {
                        message = (Message)_queue.Dequeue();
                    }
                    catch (Exception ex)
                    {
                        InternalLogger.Error("Error dequeuing message: {0}", ex.Message);
                        return;
                    }

                    var request = new SendEmailRequest();
                    request.WithDestination(new Destination(To.Split(',').ToList()));
                    request.WithMessage(message);
                    request.WithSource(From);

                    try
                    {
                        var response = _ses.SendEmail(request);

                        var result = response.SendEmailResult;

                        InternalLogger.Debug("Amazon SES message sent, id: {0}", result.MessageId);
                    }
                    catch (Exception ex)
                    {
                        InternalLogger.Error("Error sending message: {0}", ex.Message);
                    }

                    // sleep for the required send rate quota
                    Thread.Sleep((int)(1000 / _quota.GetSendQuotaResult.MaxSendRate));
                }
            });
            _mta.Start();
        }
开发者ID:sdolier,项目名称:NLog.Targets.AmazonSES,代码行数:68,代码来源:SESTarget.cs

示例4: SendEmail

        public bool SendEmail(String From, String To, String Subject, String Text, String HTML, String emailReplyTo, String returnPath)
        {
            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);

             Message message = new Message();

             message.WithBody(body);

             message.WithSubject(subject);
             //AmazonSimpleEmailServiceConfig config = new AmazonSimpleEmailServiceConfig();
             //config.ServiceURL = "http://aws.amazon.com/articles/3051?_encoding=UTF8&jiveRedirect=1";
             //config.ProxyPort = 465;

            // AmazonSimpleEmailService ses = new AmazonSimpleEmailServiceClient(awsAccessKeyId, awsSecretAccessKey);

             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;

             Console.WriteLine("Email sent.");

             Console.WriteLine(String.Format("Message ID: {0}",result.MessageId));

             return true;

             }

             catch (Exception ex)
            {

             Console.WriteLine(ex.Message);

             return false;

             }
//.........这里部分代码省略.........
开发者ID:shekar348,项目名称:1PointOne,代码行数:101,代码来源:AWS.aspx.cs

示例5: SendEmail

        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)
            {
                try
                {

                    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);
                    }

                    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;
                }
                finally
                {
                    String queueMessage = String.Format("From: {1}{0}To: {2}{0}Subject: {3}{0}Message:{0}{4}",
                                                        Environment.NewLine, From, To, Subject, Text ?? HTML);
                    QueueSupport.CurrStatisticsQueue.AddMessage(new CloudQueueMessage(queueMessage));
                }
            }

            Console.WriteLine("Specify Text and/or HTML for the email body!");

            return false;
//.........这里部分代码省略.........
开发者ID:kallex,项目名称:Caloom,代码行数:101,代码来源:EmailSupport.cs

示例6: SendEmail

    public string SendEmail(Hashtable State, string from, string to, string cc, string bcc, string subject, string body, string attach_path, bool isBodyHtml)
    {
        string AWSAccessKey = ConfigurationManager.AppSettings["AWSAccessKey"];
        string AWSSecretKey = ConfigurationManager.AppSettings["AWSSecretKey"];

        AmazonSimpleEmailService ses = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(AWSAccessKey, AWSSecretKey);

        SendEmailRequest request = new SendEmailRequest();
        Destination destination = new Destination();

        List<String> To = new List<String>(to.Replace(", ", ",").Split(','));
        destination.WithToAddresses(To);

        if (cc != null && cc.Length > 0)
        {
            List<String> CC = new List<String>(cc.Replace(", ", ",").Split(','));
            destination.WithCcAddresses(CC);
        }

        if (bcc != null && bcc.Length > 0)
        {
            List<String> BCC = new List<String>(bcc.Replace(", ", ",").Split(','));
            destination.WithBccAddresses(BCC);
        }

        request.WithDestination(destination);

        Content SESsubject = new Content();
        SESsubject.WithCharset("UTF-8");
        SESsubject.WithData(subject);

        Body SESbody = new Body();
        if (isBodyHtml)
        {
            Content SEShtml = new Content();
            SEShtml.WithCharset("UTF-8");
            SEShtml.WithData(body);
            SESbody.WithHtml(SEShtml);
        }
        else
        {
            Content text = new Content();
            text.WithCharset("UTF-8");
            text.WithData(body);
            SESbody.WithText(text);
        }

        Message message = new Message();
        message.WithBody(SESbody);
        message.WithSubject(SESsubject);

        request.WithMessage(message);
        request.WithSource(from);

        List<String> replyto = new List<String>(from.Replace(", ", ",").Split(','));
        request.WithReplyToAddresses(replyto);

           /* if (returnPath != null)
        {
            request.WithReturnPath(returnPath);
        }*/

        try
        {
            SendEmailResponse response = ses.SendEmail(request);
            SendEmailResult result = response.SendEmailResult;
            return "OK";
        }
        catch (Exception ex)
        {
            Util util = new Util();
            util.LogError(State, ex);
            return ex.Message;
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:75,代码来源:AmazonSES.cs

示例7: SendEmail

        ///<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;
        }
开发者ID:RomaKiev1,项目名称:AdSaverJobs,代码行数:79,代码来源:SendEmailJob.cs

示例8: SendEmail

        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!");
        }
开发者ID:beaujackson,项目名称:AESMailer,代码行数:76,代码来源:Mailer.cs

示例9: SendMail

        public override void SendMail(object sender, EmailToSendArgs e)
        {
            if (nextCanSend > DateTime.Now)
                System.Threading.Thread.Sleep(nextCanSend.Subtract(DateTime.Now));

            using (var ses = Amazon.AWSClientFactory.CreateAmazonSimpleEmailServiceClient(
                _configuration.Amazon.Key,
                _configuration.Amazon.Secret))
            {
                Destination destination = new Destination();
                destination.WithToAddresses(e.Message.To.ToStringArray());

                Content subject = new Content();
                subject.WithCharset("UTF-8");
                subject.WithData(e.Message.Subject);

                Body body = new Body();
                if (!string.IsNullOrWhiteSpace(e.Message.Html))
                {
                    Content html = new Content();
                    html.WithCharset("UTF-8");
                    html.WithData(e.Message.Html);
                    body.WithHtml(html);
                }

                if (!string.IsNullOrWhiteSpace(e.Message.Text))
                {
                    Content text = new Content();
                    text.WithCharset("UTF-8");
                    text.WithData(e.Message.Text);
                    body.WithText(text);
                }

                Message message = new Message();
                message.WithBody(body);
                message.WithSubject(subject);

                SendEmailRequest request = new SendEmailRequest();
                request.WithDestination(destination);
                request.WithMessage(message);
                request.WithSource(e.Message.From);

                try
                {
                    Console.WriteLine("sending email from {0}", e.Message.From);
                    SendEmailResponse response = ses.SendEmail(request);

                    SendEmailResult result = response.SendEmailResult;

                    logger.Debug("Email sent.");
                    logger.Debug(String.Format("Message ID: {0}",
                                               result.MessageId));

                    nextCanSend = _lastSend.AddSeconds(_maxSendRate);
                }
                catch (Exception ex)
                {
                    logger.Fatal("failed to send email", ex);

                    e.SendingFailed = true;
                }
            }
            base.SendMail(sender, e);
        }
开发者ID:andrewmyhre,项目名称:EmailProcessing,代码行数:64,代码来源:AmazonSESEmailSender.cs


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