Represents the destination of the message, consisting of To:, CC:, and BCC: fields.

        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);
        }
Example #2
0
        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;
                }
            }
        }
Example #3
0
    public static void SESSendEmail()
    {
      #region SESSendEmail
      var sesClient = new AmazonSimpleEmailServiceClient();           
      
      var dest = new Destination
      {
        ToAddresses = new List<string>() { "*****@*****.**" },
        CcAddresses = new List<string>() { "*****@*****.**" }
      };

      var from = "*****@*****.**";
      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
    }
Example #4
0
        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());
                }
            }
        }
		public  AmazonWebServiceResponse ExecuteService(ValidationResult param, AmazonSimpleEmailService emailService) {
			var destination = new Destination()
					.WithToAddresses(param.EmailAddresses)
					.WithCcAddresses(param.CC)
					.WithBccAddresses(param.BCC);

			emailService.SendEmail(new SendEmailRequest(param.SenderEmail,destination, GetMessage(param.Subject, param.Body)));

			return null;
		}
 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);
     }
 }
Example #7
0
        public IEmailSendResult Send(IEmailMessage message)
        {
            var asmRequest = new ASM.ListVerifiedEmailAddressesRequest();
            var ses        = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(_awsAccessKey, _awsSecretKey, RegionEndpoint.USEast1);

            try
            {
                var awsConfirmResponse = ses.ListVerifiedEmailAddresses();
                var verifiedEmails     = awsConfirmResponse.VerifiedEmailAddresses;
                if (verifiedEmails.Contains(_contactEmail) && verifiedEmails.Contains(_contactFromEmail))
                {
                    var emailRequest = new ASM.SendEmailRequest();
                    var destination  = new ASM.Destination();
                    destination.ToAddresses.Add(_contactEmail);

                    var awsMessage = CreateMessage(message);
                    emailRequest.Destination      = destination;
                    emailRequest.Message          = awsMessage;
                    emailRequest.Source           = _contactFromEmail;
                    emailRequest.ReplyToAddresses = new List <string>()
                    {
                        message.Email
                    };

                    var awsSendResponse = ses.SendEmail(emailRequest);
                    var messageId       = awsSendResponse.MessageId;

                    return(new EmailSendResult {
                        Success = (awsSendResponse.HttpStatusCode == System.Net.HttpStatusCode.OK),
                        MessageId = awsSendResponse.MessageId,
                        Message = string.Empty
                    });
                }
                else
                {
                    return(new EmailSendResult
                    {
                        Success = false,
                        MessageId = string.Empty,
                        Message = string.Format("Unable to verify email address. {0} or {1}", _contactEmail, _contactFromEmail)
                    });
                }
            }
            catch (Exception ex)
            {
                return(new EmailSendResult
                {
                    Success = false,
                    MessageId = string.Empty,
                    Message = ex.Message
                });
            }
        }
Example #8
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;
        }
Example #9
0
        public void Send(string from, IEnumerable<string> to, IEnumerable<string> bcc, string subject, string body)
        {
            var bodyContent = new Content(body)
            {
                Charset = "UTF-8"
            };

            var message = new Message(new Content(subject), new Body { Html = bodyContent });

            var destinations = new List<Destination>();
            var destination = new Destination();

            if (to != null)
            {
                foreach (var email in to)
                {
                    if(string.IsNullOrEmpty(email))
                        throw new ArgumentException("To Email can not be null or empty");

                    destination.ToAddresses.Add(email);

                    if (destination.ToAddresses.Count != _sender.MaxRecipientPerBatch) continue;

                    destinations.Add(destination);
                    destination = new Destination();
                }
            }

            if (bcc != null)
            {
                foreach (var email in bcc)
                {
                    if (string.IsNullOrEmpty(email))
                        throw new ArgumentException("Bbc Email can not be null or empty");

                    destination.BccAddresses.Add(email);

                    if (destination.ToAddresses.Count + destination.BccAddresses.Count != _sender.MaxRecipientPerBatch) continue;

                    destinations.Add(destination);
                    destination = new Destination();
                }
            }

            if (destination.ToAddresses.Count + destination.BccAddresses.Count != 0)
                destinations.Add(destination);

            foreach (var d in destinations)
                _sender.Send(new SendEmailRequest(from, d, message));
        }
Example #10
0
        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("*****@*****.**");
            Destination des = new Destination(toaddress);
            request.Destination = des;
            request.Source = "*****@*****.**";
            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("*****@*****.**"); //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));
        }
 /// <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("*****@*****.**");
         client.SendEmail(request);
     }
 }
Example #12
0
        /// <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;
            }
        }
        public void sendEmailToAuthenticateAUser(Users user)
        {
            try
            {
                System.Collections.Generic.List<string> listColl = new System.Collections.Generic.List<string>();
                ////TODO - Write a simple loop to add the recipents email addresses to the listColl object.
                listColl.Add(user.userName.ToString());

                Amazon.SimpleEmail.AmazonSimpleEmailServiceClient client = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient("AKIAJUPAMCIGTBC2ODXQ", "s7PkEfwVmhbzWT5PFeN5CV3ZzSPemgaaxnwa32pp");
                SendEmailRequest mailObj = new SendEmailRequest();

                Destination destinationObj = new Destination(listColl);

                mailObj.Source = "*****@*****.**";
                ////The from email address
                mailObj.ReturnPath = "*****@*****.**";
                ////The email address for bounces
                mailObj.Destination = destinationObj;

                string urlLink = "http://ec2-177-71-137-221.sa-east-1.compute.amazonaws.com/smartaudiocityguide/User/authenticateUser/?hash=" + user.hash;
                ////Create Message
                Amazon.SimpleEmail.Model.Content emailSubjectObj = new Amazon.SimpleEmail.Model.Content("Authentication for Smart Audio City Guide");
                Amazon.SimpleEmail.Model.Content emailBodyContentObj = new Amazon.SimpleEmail.Model.Content(@"<htm>
                <head>
                <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
                <title>Smart Audio City Guide</title>
                </head>
                <body>
                <div>
                    <a> Welcome " + user.name + "to Smart Audio City Guide </a><br/><a>Click on the link to authenticate your account: <a href='"+urlLink+"'>"+ urlLink+ "</a></a></div></body>");

                Amazon.SimpleEmail.Model.Body emailBodyObj = new Amazon.SimpleEmail.Model.Body();
                emailBodyObj.Html = emailBodyContentObj;
                Message emailMessageObj = new Message(emailSubjectObj, emailBodyObj);
                mailObj.Message = emailMessageObj;

                dynamic response2 = client.SendEmail(mailObj);
            }
            catch (Exception)
            {

            }
        }
 public Task<string> Send(IEnumerable<string> to, IEnumerable<string> cc, string from, string title, string htmlBody, string textBody)
 {
     AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(_accessKey, _secretKey);
     Destination destination = new Destination();
     destination.ToAddresses = to.ToList();
     Content subject = new Content(title);
     Body bodyContent = new Body()
     {
         Html = htmlBody == null ? null : new Content(htmlBody),
         Text = textBody == null ? null : new Content(textBody)
     };
     Message message = new Message(subject, bodyContent);
     SendEmailRequest request = new SendEmailRequest
     {
         ReplyToAddresses = new List<string>() {@from},
         Destination = destination,
         Message = message
     };
     SendEmailResponse response = client.SendEmail(request);
     return Task.FromResult(response.MessageId);
 }
        public void SendEmail()
        {
            var client = Amazon.AWSClientFactory.CreateAmazonSimpleEmailServiceClient(EmailProcessingConfigurationManager.Section.Amazon.Key, EmailProcessingConfigurationManager.Section.Amazon.Secret);

            Destination destination = new Destination();
            destination.WithToAddresses("*****@*****.**");

            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("*****@*****.**");

            client.SendEmail(request);
        }
Example #16
0
        public static bool SendEmailWithAmazone(string FROM, string TO, string SUBJECT, string BODY, string AWSAccessKey, string AWSSecrectKey, string NameSender)
        {
            log4net.ILog log = log4net.LogManager.GetLogger("ErrorRollingLogFileAppender");
            try
            {
                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 e)
                    {
                        log.Error("ProcessSendEmail-callSendBulkMail_BySubGroup" + e);
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.ToString()); log.Error("ProcessSendEmail-callSendBulkMail_BySubGroup" + ex);return false;
            }
        }
Example #17
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;
        }
Example #18
0
 /// <summary>
 /// Instantiates SendEmailRequest with the parameterized properties
 /// </summary>
 /// <param name="source">The email address that is sending the email. This email address must be either individually verified with Amazon SES, or from a domain that has been verified with Amazon SES. For information about verifying identities, see the <a href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html">Amazon SES Developer Guide</a>. If you are sending on behalf of another user and have been permitted to do so by a sending authorization policy, then you must also specify the <code>SourceArn</code> parameter. For more information about sending authorization, see the <a href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html">Amazon SES Developer Guide</a>.  In all cases, the email address must be 7-bit ASCII. If the text must contain any other characters, then you must use MIME encoded-word syntax (RFC 2047) instead of a literal string. MIME encoded-word syntax uses the following form: <code>=?charset?encoding?encoded-text?=</code>. For more information, see <a href="http://tools.ietf.org/html/rfc2047">RFC 2047</a>. </param>
 /// <param name="destination">The destination for this email, composed of To:, CC:, and BCC: fields.</param>
 /// <param name="message">The message to be sent.</param>
 public SendEmailRequest(string source, Destination destination, Message message)
 {
     _source = source;
     _destination = destination;
     _message = message;
 }
Example #19
0
        //Send notification to user via email.
        /// <summary>
        /// Uses SES to send an email to a user.
        /// </summary>
        /// <param name="email">The email.</param>
        private void SendEmail(String email)
        {
            try
            {
                String[] arrayTO = new String[1];
                arrayTO[0] = email;

                List<string> listTO = arrayTO.ToList<String>();

                // Construct an object to contain the recipient address.
                Destination destination = new Destination().WithToAddresses(listTO);

                String FROM = "*****@*****.**";
                String SUBJECT = "Welcome to Cookbook!";
                String BODY = "Welcome to Cookbook! Thank you so much for joining us. We hope that you will enjoy using our website.";

                // Create the subject and body of the message.
                Content subject = new Content().WithData(SUBJECT);
                Content textBody = new Content().WithData(BODY);
                Body body = new Body().WithText(textBody);

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

                // Assemble the email.
                SendEmailRequest request = new SendEmailRequest().WithSource(FROM).WithDestination(destination).WithMessage(message);

                AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient();

                SendEmailResponse response = client.SendEmail(request);
                Console.WriteLine("Sent successfully.");

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #20
0
 /// <summary>
 /// Instantiates SendEmailRequest with the parameterized properties
 /// </summary>
 /// <param name="source">The email address that is sending the email. This email address must be either individually verified with Amazon SES, or from a domain that has been verified with Amazon SES. For information about verifying identities, see the <a href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html">Amazon SES Developer Guide</a>. If you are sending on behalf of another user and have been permitted to do so by a sending authorization policy, then you must also specify the <code>SourceArn</code> parameter. For more information about sending authorization, see the <a href="http://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html">Amazon SES Developer Guide</a>.  In all cases, the email address must be 7-bit ASCII. If the text must contain any other characters, then you must use MIME encoded-word syntax (RFC 2047) instead of a literal string. MIME encoded-word syntax uses the following form: <code>=?charset?encoding?encoded-text?=</code>. For more information, see <a href="https://tools.ietf.org/html/rfc2047">RFC 2047</a>. </param>
 /// <param name="destination">The destination for this email, composed of To:, CC:, and BCC: fields.</param>
 /// <param name="message">The message to be sent.</param>
 public SendEmailRequest(string source, Destination destination, Message message)
 {
     _source      = source;
     _destination = destination;
     _message     = message;
 }
 /// <summary>
 /// Sets the Destination property
 /// </summary>
 /// <param name="destination">The value to set for the Destination property </param>
 /// <returns>this instance</returns>
 public SendEmailRequest WithDestination(Destination destination)
 {
     this.destination = destination;
     return(this);
 }
 /// <summary>
 /// Constructs a new SendEmailRequest object.
 /// Callers should use the properties or fluent setter (With...) methods to
 /// initialize any additional object members.
 /// </summary>
 ///
 /// <param name="source"> The sender's email address. </param>
 /// <param name="destination"> The destination for this email, composed of To:, From:, and CC: fields. </param>
 /// <param name="message"> The message to be sent. </param>
 public SendEmailRequest(string source, Destination destination, Message message)
 {
     this.source      = source;
     this.destination = destination;
     this.message     = message;
 }
        /// <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);
            }
        }
Example #24
0
        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;

             }

             }

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

             return false;
        }
        public static void SendEmail(string fromEmailAddress, string fromFriendlyName, string toEmailAddress, string emailSubject, string emailBody)
        {

/*

            var client = new AmazonSimpleEmailServiceClient(Settings.Default.AWSAccessKey, 
                                                           Settings.Default.AWSSecretKey,
                                                            Amazon.RegionEndpoint.EUWest1);
            
            var client = new AmazonSimpleEmailServiceClient("AKIAIJINFUWK57TVYABQ",
                                                           "AosdbK3YfN8zvFltHNDuxFZrHVZNlLeBZQ1pGKG8dFCd",
                                                            Amazon.RegionEndpoint.EUWest1);
            */
            /*
            var destination = new Destination(new List<string>() {toEmailAddress});
            var subjectContent = new Content(subject);
            var bodyContent = new Content(body);
            var messageBody = new Body(bodyContent);
            var message = new Message(subjectContent, messageBody);

            var request = new SendEmailRequest(fromEmailAddress, destination, message);
           
            client.SendEmail(request);
            */

            String FROM = fromEmailAddress;  // Replace with your "From" address. This address must be verified.
             String TO = toEmailAddress; // Replace with a "To" address. If you have not yet requested
            // production access, this address must be verified.

            const String SUBJECT = "Amazon SES test (AWS SDK for .NET)";
            const String BODY = "This email was sent through Amazon SES by using the AWS SDK for .NET.";

            // Construct an object to contain the recipient address.
            Destination destination = new Destination();
            destination.ToAddresses = (new List<string>() { TO });

            // Create the subject and body of the message.
            Content subject = new Content(SUBJECT);
            Content textBody = new Content(BODY);
            Body body = new Body(textBody);

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

            // Assemble the email.
            SendEmailRequest request = new SendEmailRequest(FROM, destination, message);

            // Choose the AWS region of the Amazon SES endpoint you want to connect to. Note that your production 
            // access status, sending limits, and Amazon SES identity-related settings are specific to a given 
            // AWS region, so be sure to select an AWS region in which you set up Amazon SES. Here, we are using 
            // the US East (N. Virginia) region. Examples of other regions that Amazon SES supports are USWest2 
            // and EUWest1. For a complete list, see http://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html 
            Amazon.RegionEndpoint REGION = Amazon.RegionEndpoint.EUWest1;

            // Instantiate an Amazon SES client, which will make the service call.
            var client = new AmazonSimpleEmailServiceClient(Settings.Default.AWSAccessKey,
                                                           Settings.Default.AWSSecretKey,
                                                            Amazon.RegionEndpoint.EUWest1);

            // Send the email.
          //  client.VerifyEmailAddress(new VerifyEmailAddressRequest() {EmailAddress = fromEmailAddress});


                client.SendEmail(request);
                Console.WriteLine("Email sent!");


        }
Example #26
0
        public SendStatus SendEmail(MailMessage mailMessage)
        {
            //Check if we need to query stats
            RefreshQuotaIfNeeded();
            if (_quota != null)
            {
                lock (SynchRoot)
                {
                    if (_quota.Max24HourSend <= _quota.SentLast24Hours)
                    {
                        //Quota exceeded
                        //Queu next refresh to +24 hours
                        _lastRefresh = DateTime.UtcNow.AddHours(24);
                        _log.WarnFormat("quota limit reached. setting next check to: {0}", _lastRefresh);
                        return SendStatus.QuotaLimit;
                    }
                }
            }



            var destination = new Destination
            {
                ToAddresses = mailMessage.To.Select(adresses => adresses.Address).ToList(),
                BccAddresses = mailMessage.Bcc.Select(adresses => adresses.Address).ToList(),
                CcAddresses = mailMessage.CC.Select(adresses => adresses.Address).ToList(),

            };

            var body = new Body(new Content(mailMessage.Body) { Charset = Encoding.UTF8.WebName });

            if (mailMessage.AlternateViews.Count > 0)
            {
                //Get html body
                foreach (var alternateView in mailMessage.AlternateViews)
                {
                    if ("text/html".Equals(alternateView.ContentType.MediaType, StringComparison.OrdinalIgnoreCase))
                    {
                        var stream = alternateView.ContentStream;
                        var buf = new byte[stream.Length];
                        stream.Read(buf, 0, buf.Length);
                        stream.Seek(0, SeekOrigin.Begin);//NOTE:seek to begin to keep HTML body
                        body.Html = new Content(Encoding.UTF8.GetString(buf)) { Charset = Encoding.UTF8.WebName };
                        break;
                    }
                }
            }

            var message = new Message(new Content(mailMessage.Subject), body);

            var seRequest = new SendEmailRequest(mailMessage.From.ToEncodedStringEx(), destination, message);
            if (mailMessage.ReplyTo != null)
                seRequest.ReplyToAddresses.Add(mailMessage.ReplyTo.Address);

            ThrottleIfNeeded();

            var response = _emailService.SendEmail(seRequest);
            _lastSend = DateTime.UtcNow;
            return response != null ? SendStatus.Ok : SendStatus.Failed;
        }
Example #27
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);
        }
Example #28
0
        private NoticeSendResult SendMessage(NotifyMessage m)
        {
            //Check if we need to query stats
            RefreshQuotaIfNeeded();
            if (quota != null)
            {
                lock (locker)
                {
                    if (quota.Max24HourSend <= quota.SentLast24Hours)
                    {
                        //Quota exceeded, queue next refresh to +24 hours
                        lastRefresh = DateTime.UtcNow.AddHours(24);
                        log.WarnFormat("Quota limit reached. setting next check to: {0}", lastRefresh);
                        return NoticeSendResult.SendingImpossible;
                    }
                }
            }

            var dest = new Destination
            {
                ToAddresses = m.To.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(a => MailAddressUtils.Create(a).Address).ToList(),
            };

            var subject = new Content(MimeHeaderUtils.EncodeMime(m.Subject)) { Charset = Encoding.UTF8.WebName, };

            Body body;
            if (m.ContentType == Pattern.HTMLContentType)
            {
                body = new Body(new Content(HtmlUtil.GetText(m.Content)) { Charset = Encoding.UTF8.WebName });
                body.Html = new Content(GetHtmlView(m.Content)) { Charset = Encoding.UTF8.WebName };
            }
            else
            {
                body = new Body(new Content(m.Content) { Charset = Encoding.UTF8.WebName });
            }

            var from = MailAddressUtils.Create(m.From).ToEncodedString();
            var request = new SendEmailRequest(from, dest, new Message(subject, body));
            if (!string.IsNullOrEmpty(m.ReplyTo))
            {
                request.ReplyToAddresses.Add(MailAddressUtils.Create(m.ReplyTo).Address);
            }

            ThrottleIfNeeded();

            var response = ses.SendEmail(request);
            lastSend = DateTime.UtcNow;

            return response != null ? NoticeSendResult.OK : NoticeSendResult.TryOnceAgain;
        }
Example #29
0
        /// <summary>
        /// Method to send email through cloud service.
        /// If isHtml is true the body is interpreted as HTML content.
        /// </summary>
        public bool SendBulkEmail(string subject, string bodyText, string fromAddress, List<string> toAddresses, List<string> ccAddresses, List<string> replyToAddresses, bool isHtml)
        {
            try
            {
                if (replyToAddresses == null || replyToAddresses.Count == 0)
                {
                    replyToAddresses = new List<string>();
                    replyToAddresses.Add(fromAddress);
                }

                Message message = new Message();
                message.Body = new Body();

                Content bodyContent = new Content();
                bodyContent.Charset = "UTF-8";
                bodyContent.Data = bodyText;

                if (isHtml)
                    message.Body.Html = bodyContent;
                else
                    message.Body.Text = bodyContent;

                Content subjectContent = new Content();
                subjectContent.Charset = "UTF-8";
                subjectContent.Data = subject;

                message.Subject = subjectContent;

                Destination destination = new Destination(toAddresses);
                if (ccAddresses != null && ccAddresses.Count > 0)
                    destination.CcAddresses = ccAddresses;

                SendEmailRequest sendEmailRequest = new SendEmailRequest()
                    .WithDestination(destination)
                    .WithMessage(message)
                    .WithReplyToAddresses(replyToAddresses)
                    .WithSource(fromAddress);

                //Create AWS Client
                AmazonSimpleEmailService amazonSes = AWSClientFactory.CreateAmazonSimpleEmailServiceClient(this.cloudServiceConfigProvider.AWSAccessKeyId, this.cloudServiceConfigProvider.AWSSecretKey);

                //Send email
                SendEmailResponse sendEmailResponse = amazonSes.SendEmail(sendEmailRequest);

                return true;
            }
            catch (Exception)
            {
                ///TODO: Write log
                return false;
            }
        }
 public SendEmailRequest WithDestination(Destination destination)
 {
     this.destination = destination;
     return this;
 }
 /// <summary>
 /// Constructs a new SendEmailRequest object.
 /// Callers should use the properties or fluent setter (With...) methods to
 /// initialize any additional object members.
 /// </summary>
 /// 
 /// <param name="source"> The identity's email address. </param>
 /// <param name="destination"> The destination for this email, composed of To:, CC:, and BCC: fields. </param>
 /// <param name="message"> The message to be sent. </param>
 public SendEmailRequest(string source, Destination destination, Message message)
 {
     this.source = source;
     this.destination = destination;
     this.message = message;
 }
 private Destination BuildDestination()
 {
     Destination destination = new Destination();
     destination.ToAddresses.Add("*****@*****.**");
     return destination;
 }
        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;
        }
Example #34
0
        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;
        }