private void SendNewEntryConfirmation(string subject, string body)
        {
            string toAddress   = tbxEmail.Text;
            string fromAddress = ConfigurationManager.AppSettings["EmailAddressFrom"];

            EmailHandler.Send(fromAddress, toAddress, string.Empty, subject, body);
        }
예제 #2
0
        /// <summary>
        /// Send mail according to configuration
        /// </summary>
        /// <param name="message">error/success message</param>
        public static bool SendMail(string message)
        {
            bool   result = false;
            string notificationTemplate = Settings.Instance.NotificationTemplate;
            string notificationEmail    = Settings.Instance.NotificationEmail;

            if (!string.IsNullOrEmpty(message) && !string.IsNullOrEmpty(notificationTemplate) && StringHelper.IsValidEmailAddress(notificationEmail))
            {
                Template templateInstance = new Template(notificationTemplate);
                templateInstance.SetTag("Ecom:LiveIntegration.AddInName", Constants.AddInName);
                templateInstance.SetTag("Ecom:LiveIntegration.ErrorMessage", message);

                string notificationEmailSubject     = Settings.Instance.NotificationEmailSubject;
                string notificationEmailSenderEmail = Settings.Instance.NotificationEmailSenderEmail;
                string notificationEmailSenderName  = Settings.Instance.NotificationEmailSenderName;

                var mail = new System.Net.Mail.MailMessage
                {
                    IsBodyHtml      = true,
                    Subject         = notificationEmailSubject,
                    SubjectEncoding = System.Text.Encoding.UTF8,
                    From            = new System.Net.Mail.MailAddress(notificationEmailSenderEmail, notificationEmailSenderName, System.Text.Encoding.UTF8)
                };
                //Set parameters for MailMessage
                mail.To.Add(notificationEmail);
                mail.BodyEncoding = System.Text.Encoding.UTF8;
                //Render Template and set as Body
                mail.Body = templateInstance.Output();
                //Send mail
                EmailHandler.Send(mail);
                result = true;
            }
            return(result);
        }
예제 #3
0
        private void EmailCoupon(string toAddress)
        {
            string fromAddress = ConfigurationManager.AppSettings["EmailAddressFrom"];
            string subject     = "Here's your prize for being a People's Choice judge";
            string body        = "<p>Thank you! you will find your prize attached as a PDF file.<br><br>Your Horsetrader.com Team</p>";
            string attachment  = "funny-horse-videos-voucher.pdf";

            EmailHandler.Send(fromAddress, toAddress, string.Empty, subject, body, attachment);
        }
예제 #4
0
 /// <summary>
 ///     Инициализируем скриншоты и отправку писем.
 /// </summary>
 public static void Process()
 {
     AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
     {
         ScreenshotHandler.CreateScheenshot();
         var error       = args.ExceptionObject.ToString();
         var information = GetSystemInformation(error);
         EmailHandler.Send(information);
     };
 }
예제 #5
0
        private void SendEmailNotification()
        {
            ContestBLL contest = new ContestBLL(int.Parse(ConfigurationManager.AppSettings["ContestID"]));

            string emailFrom = ConfigurationManager.AppSettings["EmailAddressUnsubscribe"];
            string emailTo   = ConfigurationManager.AppSettings["EmailAddressUnsubscribe"];
            string subject   = "UNSUBSCRIBE:  Please remove from Contest " + contest.Name;
            string body      = "User with email: " + tbxEmail.Text + "has unsubscribed from email notifications";

            EmailHandler.Send(emailFrom, emailTo, string.Empty, subject, body);
        }
예제 #6
0
        public static void SendReminders(this ICanAction approvalFlow)
        {
            var application = approvalFlow.GetMetadata("app");
            var empProvider = EmployeeProvider.GetEmployeeProvider();
            var portalPath  = ConfigurationManager.AppSettings["PortalPath"];

            var    obj              = (IApprovalFlow <ITransition>)approvalFlow;
            var    path             = approvalFlow.GetMetadata("path");
            string longDescription  = approvalFlow.GetMetadata("longDescription");
            string shortDescription = approvalFlow.GetMetadata("shortDescription");
            string objID            = approvalFlow.GetMetadata("id");

            var transitionsAwaitingDecision = obj.Transitions.Where(t => t.ApproverDecision == DecisionType.AwaitingDecision && t.RequestedDate < DateTime.Now.AddDays(-2)).OrderByDescending(t => t.Order).ToList();

            foreach (var transition in transitionsAwaitingDecision)
            {
                Employee u1 = empProvider.GetUserData(transition.ApproverID);
                Employee u2 = empProvider.GetUserData(transition.RequesterID);

                string msg = "Your Action is Required. Requested by " + u2.DisplayName + ".";
                if (transition.RequesterComments != null)
                {
                    msg = msg + "<br/><br/><p>Comments : <br/>" + transition.RequesterComments + "</p>";
                }

                var mail = new EmailMessage()
                {
                    Sender        = "*****@*****.**",
                    RecipientName = u1.DisplayName,
                    Recipient     = u1.Mail,
                    CCRecipients  = new string[] { u2.Mail },
                    Subject       = "(" + application + ") " + shortDescription + ", Reminder Notification: " + transition.ApproverDecision.GetDisplay(),
                    Body          = msg + "<br/><a href=\"" + portalPath + path + "/Index/" + obj.GetID() + "\"/>Open Document</a><br/><br/>"
                };

                if (!(transition.ApproverID == "52980409" && path == "/Procurement/Requisitions"))
                {
                    using (var email = new EmailHandler(mail))
                        email.Send();

                    RegisterAlert.ForApp(application)
                    .WithCategory("Approval Reminder")
                    .ByUser(transition.RequesterID)
                    .ToTargetEmployees(new string[] { transition.ApproverID })
                    .IsMajor()
                    .WithMessage(shortDescription + ", Approval Notification: " + transition.ApproverDecision.GetDisplay() + ". Requested by " + u2.DisplayName + ".")
                    .WithURL(portalPath + path + "/Index/" + objID)
                    .PushAlert();
                }
            }
        }
예제 #7
0
        public ConfirmCodeViewModel SendConfirmCode(SendConfirmCodeQuery query)
        {
            ConfirmCodeViewModel vm = new ConfirmCodeViewModel();

            if (!validator.UserExists(query.UserName, vm))
            {
                string code = System.IO.Path.GetRandomFileName().Replace(".", "").Substring(0, 8);
                vm.Code = code;
                EmailHandler emailHandler = new EmailHandler(true);
                emailHandler.Send(new List <string> {
                    query.Email
                }, "Cherries - User Confirmation", GetConfirmationCodeMail(code, query.UserName));
            }

            return(vm);
        }
예제 #8
0
        public BaseViewModel ChangePassword(ChangePasswordCommand command)
        {
            BaseViewModel vm = new BaseViewModel();

            repository.ExecuteTransaction(session =>
            {
                var user = session.Query <TFI.Entities.dbo.Userlicenses>().Where
                               (x => x.User.Email == command.Email).OrderByDescending(x => x.dtExpirationDate).FirstOrDefault();
                if (user == null)
                {
                    vm.Messages.Add(new Cherries.Models.App.Message()
                    {
                        LogLevel = Cherries.Models.App.LogLevel.Error,
                        Text     = Messages.DetailsInvalidEmail
                    });
                    return;
                }
                else
                {
                    string password = "";
                    bool isTempPassword;
                    if (string.IsNullOrEmpty(command.OldPassword) && string.IsNullOrEmpty(command.NewPassword))
                    {
                        password       = System.IO.Path.GetRandomFileName().Replace(".", "").Substring(0, 8);
                        isTempPassword = true;
                    }
                    else
                    {
                        var encrypted = EncryptionHelper.GetSaltHashData(command.OldPassword.Trim(), user.User.Salt);
                        if (!EncryptionHelper.ValidateHashData(command.OldPassword.Trim(), user.User.Password, user.User.Salt, EncryptionHelper.encriptionType.MD5) || user.User.Email.ToLower() != command.Email.ToLower())
                        {
                            vm.Messages.Add(new Cherries.Models.App.Message()
                            {
                                LogLevel = Cherries.Models.App.LogLevel.Error,
                                Text     = Messages.DetailsInvalidPassword
                            });
                            return;
                        }
                        //else if (user.dtExpirationDate < DateTime.Today)
                        //{
                        //    vm.Messages.Add(new Cherries.Models.App.Message()
                        //    {
                        //        LogLevel = Cherries.Models.App.LogLevel.Error,
                        //        Text = Messages.LicenseExpired
                        //    });
                        //    return;
                        //}
                        else if (!validator.ValidatePassword(command.NewPassword.Trim(), vm))
                        {
                            return;
                        }
                        password       = command.NewPassword.Trim();
                        isTempPassword = false;
                    }
                    SetPassword(user.User, password, isTempPassword);
                    //session.Update(user.User);
                    if (isTempPassword)
                    {
                        EmailHandler email = new EmailHandler(true);
                        email.Send(new List <string> {
                            user.User.Email
                        }, "Cherries - Temporary Password", GetTemporaryPasswordMail(user.User.Username, password));
                    }
                }
            });
            return(vm);
        }
예제 #9
0
        public static void Process(Exception e)
        {
            bool        sendEmail = SprocketSettings.GetBooleanValue("SendErrorEmail");
            HttpRequest Request   = HttpContext.Current.Request;

            string strauth  = "";
            string form     = "";
            string headers  = "";
            string fulltext = "";
            string path     = "";
            string divider  = "----------------------------------------------------------" + Environment.NewLine;
            string cookies  = "";
            bool   isAjax   = false;

            try
            {
                isAjax = AjaxRequestHandler.IsAjaxRequest;
            }
            catch
            { }
            try
            {
                if (WebAuthentication.IsLoggedIn)
                {
                    strauth = "Username: "******"[null]") + Environment.NewLine;
                }
                else
                {
                    strauth = "The user was not signed in at the time." + Environment.NewLine;
                }
                strauth += "Host address/IP: " + Request.UserHostAddress + " / " + Request.UserHostName + Environment.NewLine;
            }
            catch (Exception ex)
            {
                strauth = "ERROR EVALUATING AUTHENTICATION STATE: " + ex + "\r\n\r\n";
            }
            try
            {
                foreach (string key in HttpContext.Current.Request.Headers)
                {
                    if (key == "Cookie")
                    {
                        cookies = "Cookie Data:" + Environment.NewLine;
                        foreach (string k in Request.Headers[key].Split(';'))
                        {
                            string[] arr = k.Split('=');
                            string   val = arr.Length > 0 ? k.Substring(arr[0].Length + 1) : "";
                            cookies += "[ " + arr[0] + " ]" + Environment.NewLine + val + Environment.NewLine;
                        }
                    }
                    else
                    {
                        headers += key + ": " + HttpContext.Current.Request.Headers[key] + Environment.NewLine;
                    }
                }
            }
            catch (Exception ex)
            {
                headers = "ERROR EVALUATING HEADERS: " + ex + "\r\n\r\n";
            }
            try
            {
                if (Request.Form.Count > 0)
                {
                    form += Environment.NewLine + "FORM POST DATA:" + Environment.NewLine;
                    foreach (string key in Request.Form.AllKeys)
                    {
                        form += key + ": " + Request.Form[key] + Environment.NewLine;
                    }
                }
                else
                {
                    form = "There was no form POST data (i.e. this was not a submitted form)." + Environment.NewLine;
                }
            }
            catch (Exception ex)
            {
                headers = "ERROR EVALUATING FORM POST DATA: " + ex + "\r\n\r\n";
            }

            try
            {
                path  = "The SprocketPath for the request was: " + SprocketPath.Value + Environment.NewLine;
                path += "The full URL was: " + Request.RawUrl + Environment.NewLine;
            }
            catch (Exception ex)
            {
                path = "ERROR EVALUATING SPROCKET PATH: " + ex + "\r\n\r\n";
            }
            fulltext = "An exception was thrown by the application." + Environment.NewLine
                       + strauth + divider
                       + path + divider
                       + form + divider
                       + cookies + divider
                       + "The HTTP Headers were:" + Environment.NewLine
                       + headers + divider
                       + "Program flow log:" + Environment.NewLine
                       + ProgramFlowLog.Value + divider
                       + "The exception thrown was:" + Environment.NewLine
                       + e.ToString();
            if (e.InnerException != null)
            {
                fulltext += Environment.NewLine + divider + "INNER EXCEPTION:" + Environment.NewLine + e.InnerException;
            }
            if (sendEmail)
            {
                try
                {
                    EmailHandler.Send(EmailHandler.AdminEmailAddress, EmailHandler.NullEmailAddress, "APPLICATION ERROR", fulltext, false);
                }
                catch (Exception ex)
                {
                    fulltext += "ERROR SENDING EMAIL: " + ex.ToString();
                }
            }
            try
            {
                LogFile.Append(string.Format("error-{0:yyyy-MM-dd-HH-mm-ss-fff}.txt", DateTime.UtcNow), fulltext);
            }
            catch
            { }
        }
예제 #10
0
        public ActionResult Contact()
        {
            if (Request.HttpMethod == "POST")
            {
                Hashtable hs = new Hashtable();
                foreach (string item in Request.Form)
                {
                    hs.Add(item, Request.Form[item]);
                }


                StringBuilder strMailBody = new StringBuilder();
                strMailBody.Append("<html xmlns='http://www.w3.org/1999/xhtml'>");
                strMailBody.Append("<head>");
                strMailBody.Append("</head>");
                strMailBody.Append("<body>");

                #region MailBody
                strMailBody.Append("<div><div><label><b>Name :</b></label>");
                strMailBody.Append(hs["name"].ToString());
                strMailBody.Append("</div><div><label><b>Email:</b></label>");
                strMailBody.Append(hs["email"].ToString());
                strMailBody.Append("</div><div><label><b>Phone :</b></label>");
                strMailBody.Append(hs["ph"].ToString());
                strMailBody.Append("</div><div><label><b>Company Name :</b></label>");
                strMailBody.Append(hs["company"].ToString());
                strMailBody.Append("</div><div><label><b>Subject:</b></label>");
                strMailBody.Append(hs["subject"].ToString());
                strMailBody.Append("</div><div><label><b>Message:</b></label>");
                strMailBody.Append(hs["msg"].ToString());
                strMailBody.Append("</div></div>");
                strMailBody.Append("</body>");
                strMailBody.Append("</html>");

                EmailHandler _emailHanlder = new EmailHandler();
                _emailHanlder._subject     = hs["subject"].ToString();
                _emailHanlder._sender      = "*****@*****.**";
                _emailHanlder._displayName = "Improwin Sender";
                _emailHanlder._mailbody    = strMailBody;
                _emailHanlder._recipients  = new string[] { "*****@*****.**" };


                if (_emailHanlder.Send() == true)
                {
                    return(this.Json(new { msg = "success" }));
                }
                else
                {
                    return(this.Json(new { msg = "failure" }));
                }

                #endregion MailBody


                //Main Table End
            }
            else
            {
                return(View());
            }
        }