Example #1
0
        public async Task <AlertSendStatus> Send()
        {
            String url      = "https://www.smsglobal.com/http-api.php";
            String username = "******";
            String password = "******";
            String Body     = WebUtility.UrlEncode(_SMSBody);

            string data =
                "action=sendsms" +
                "&user="******"&password="******"&from=EXPONENT" +
                "&to=" + _SMSNumber +
                "&text=" + Body +
                "&maxsplit=3";

            HttpPostStatus PostResult = await Post(url, data);

            var result = new AlertSendStatus {
                IsSend          = PostResult.StatusCode == HttpStatusCode.OK,
                ProviderMessage = PostResult.ResponseText
            };

            return(result);
        }
        public AlertSendStatus Send()
        {
            AlertSendStatus alertSendStatus = new AlertSendStatus {
                IsSend          = false,
                ProviderMessage = "Waiting"
            };

            try {
                CDO.Message        oMsg = new CDO.Message();
                CDO.IConfiguration iConfg;

                iConfg = oMsg.Configuration;

                ADODB.Fields oFields;
                oFields = iConfg.Fields;

                // Set configuration.
                oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value             = 2;
                oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value            = "smtp.gmail.com";
                oFields["http://schemas.microsoft.com/cdo/configuration/smptserverport"].Value        = 587;
                oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value      = 1;
                oFields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"].Value            = true;
                oFields["http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"].Value = 60;
                oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value          = "*****@*****.**";
                oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value          = "drone123";

                oFields.Update();

                oMsg.CreateMHTMLBody(emailMessage.EmailURL);
                oMsg.Subject = emailMessage.EmailSubject;

                //TODO: Change the To and From address to reflect your information.
                oMsg.From = "Exponent <*****@*****.**>";
                oMsg.To   = emailMessage.ToAddress;

                //ADD attachment.
                //TODO: Change the path to the file that you want to attach.
                if (!String.IsNullOrEmpty(emailMessage.Attachments))
                {
                    foreach (String FileWithPath in emailMessage.Attachments.Split(','))
                    {
                        oMsg.AddAttachment(FileWithPath);
                    }
                }

                oMsg.Send();
                alertSendStatus.IsSend          = true;
                alertSendStatus.ProviderMessage = "Send Successfully";
            } catch (Exception e) {
                alertSendStatus.ProviderMessage = e.Message;
            }

            return(alertSendStatus);
        }
Example #3
0
        private static AlertSendStatus SendEmail(PortalAlertEmail portalAlertEmail)
        {
            AlertSendStatus alertSendStatus = new AlertSendStatus {
                IsSend = false
            };
            EmailMessage email = new EmailMessage(portalAlertEmail);

            Task taskA = Task.Factory.StartNew(() => { alertSendStatus = email.Send(); });

            taskA.Wait();

            return(alertSendStatus);
        }
Example #4
0
        public static async Task <bool> SendQueue()
        {
            PortalAlertEmail portalAlertEmail;
            AlertSendStatus  stat = null;

            if (!alertQueue.Any())
            {
                return(false);
            }

            //Lock que items for safe threading
            lock (_lockerQueue) {
                portalAlertEmail = alertQueue[0];
                alertQueue.RemoveAt(0);
            }

            switch (portalAlertEmail.SendType.ToLower())
            {
            case "sms":
                stat = await SendSMS(portalAlertEmail);

                break;

            case "email":
                stat = SendEmail(portalAlertEmail);
                break;
            }

            if (stat != null)
            {
                portalAlertEmail.IsSend     = (byte)(stat.IsSend ? 1 : 0);
                portalAlertEmail.SendOn     = DateTime.UtcNow;
                portalAlertEmail.SendStatus = stat.ProviderMessage;
                using (FlightProcessorConnection cn = new FlightProcessorConnection()) {
                    var entry = cn.Entry(portalAlertEmail);
                    entry.State = EntityState.Modified;
                    await cn.SaveChangesAsync();
                }
                lock (_lockerResetQueue) {
                    alertQueueProcessed.Add(portalAlertEmail);
                }
                return(true);
            }
            return(false);
        }