Beispiel #1
0
        public CallContext SendMailToAdministrator(SendMailHelper sendMailHelper)
        {
            CallContext callContext = new CallContext();



            SetDetaultKvParams(callContext);


            SendMailAction(GetSettingByCode(ETEMEnums.AppSettings.EmailForSending).SettingValue, GetSettingByCode(ETEMEnums.AppSettings.EmailForReciveError).SettingValue,
                           sendMailHelper.SubjectBG, sendMailHelper.BodyBG, "Системен e-mail", new List <string>(), callContext, true);
            //
            return(callContext);
        }
Beispiel #2
0
        protected void btnSendEmails_Click(object sender, EventArgs e)
        {
            try
            {


                string errorMsg = string.Empty;
                if (string.IsNullOrEmpty(this.tbxSubject.Text.Trim()))
                {
                    errorMsg = "`" + this.lbSubject.Text + "`";
                }
                if (string.IsNullOrEmpty(this.tbxBody.Text.Trim()))
                {
                    errorMsg += (string.IsNullOrEmpty(errorMsg) ? string.Empty : ", ") + "`" + this.lbBody.Text + "`";
                }

                if (!string.IsNullOrEmpty(errorMsg))
                {
                    base.ShowJavaScriptMSG(string.Format(BaseHelper.GetCaptionString("Form_Email_Subject_And_Body_Required"), errorMsg));
                    return;
                }

                List<int> listSelectedIDs = new List<int>();
                CheckBox chbxCheckForSend = new CheckBox();
                HiddenField hdnIdEntity = new HiddenField();
                foreach (GridViewRow row in this.gvUsers.Rows)
                {
                    chbxCheckForSend = row.FindControl("chbxCheckForSend") as CheckBox;

                    if (chbxCheckForSend != null && chbxCheckForSend.Checked)
                    {
                        hdnIdEntity = row.FindControl("hdnIdEntity") as HiddenField;

                        if (hdnIdEntity != null && !listSelectedIDs.Contains(Int32.Parse(hdnIdEntity.Value)))
                        {
                            listSelectedIDs.Add(Int32.Parse(hdnIdEntity.Value));
                        }
                    }
                }

                this.CallContext.CurrentYear = Convert.ToInt32(GeneralPage.GetSettingByCode(ETEMEnums.AppSettings.CurrentYear).SettingValue);

                if (this.CallContext.ListKvParams.Where(w => w.Key == ETEMEnums.AppSettings.SendExternalMail.ToString()).Count() == 0)
                {
                    this.CallContext.ListKvParams.Add(new KeyValuePair<string, object>(ETEMEnums.AppSettings.SendExternalMail.ToString(),
                                                      GetSettingByCode(ETEMEnums.AppSettings.SendExternalMail).SettingValue));
                }
                if (this.CallContext.ListKvParams.Where(w => w.Key == ETEMEnums.AppSettings.DefaultEmail.ToString()).Count() == 0)
                {
                    this.CallContext.ListKvParams.Add(new KeyValuePair<string, object>(ETEMEnums.AppSettings.DefaultEmail.ToString(),
                                                      GetSettingByCode(ETEMEnums.AppSettings.DefaultEmail).SettingValue));
                }
                if (this.CallContext.ListKvParams.Where(w => w.Key == ETEMEnums.AppSettings.MailServer.ToString()).Count() == 0)
                {
                    this.CallContext.ListKvParams.Add(new KeyValuePair<string, object>(ETEMEnums.AppSettings.MailServer.ToString(),
                                                      GetSettingByCode(ETEMEnums.AppSettings.MailServer).SettingValue));
                }
                if (this.CallContext.ListKvParams.Where(w => w.Key == ETEMEnums.AppSettings.MailServerPort.ToString()).Count() == 0)
                {
                    this.CallContext.ListKvParams.Add(new KeyValuePair<string, object>(ETEMEnums.AppSettings.MailServerPort.ToString(),
                                                      GetSettingByCode(ETEMEnums.AppSettings.MailServerPort).SettingValue));
                }
                if (this.CallContext.ListKvParams.Where(w => w.Key == ETEMEnums.AppSettings.MailFromPassword.ToString()).Count() == 0)
                {
                    this.CallContext.ListKvParams.Add(new KeyValuePair<string, object>(ETEMEnums.AppSettings.MailFromPassword.ToString(),
                                                      GetSettingByCode(ETEMEnums.AppSettings.MailFromPassword).SettingValue));
                }
                if (this.CallContext.ListKvParams.Where(w => w.Key == ETEMEnums.AppSettings.MailServerPop3.ToString()).Count() == 0)
                {
                    this.CallContext.ListKvParams.Add(new KeyValuePair<string, object>(ETEMEnums.AppSettings.MailServerPop3.ToString(),
                                                      GetSettingByCode(ETEMEnums.AppSettings.MailServerPop3).SettingValue));
                }
                if (this.CallContext.ListKvParams.Where(w => w.Key == ETEMEnums.AppSettings.MailServerPop3Port.ToString()).Count() == 0)
                {
                    this.CallContext.ListKvParams.Add(new KeyValuePair<string, object>(ETEMEnums.AppSettings.MailServerPop3Port.ToString(),
                                                      GetSettingByCode(ETEMEnums.AppSettings.MailServerPop3Port).SettingValue));
                }
                if (this.CallContext.ListKvParams.Where(w => w.Key == ETEMEnums.AppSettings.WaitCheckMailDeliveryInMinutes.ToString()).Count() == 0)
                {
                    this.CallContext.ListKvParams.Add(new KeyValuePair<string, object>(ETEMEnums.AppSettings.WaitCheckMailDeliveryInMinutes.ToString(),
                                                      GetSettingByCode(ETEMEnums.AppSettings.WaitCheckMailDeliveryInMinutes).SettingValue));
                }

                SendMailHelper sendMailData = new SendMailHelper()
                {
                    SubjectBG = this.tbxSubject.Text.Trim(),
                    BodyBG = this.tbxBody.Text.Trim()
                };

                ICollection<AbstractSearch> searchCriteria = new List<AbstractSearch>();
                AddCustomSearchCriterias(searchCriteria);

                this.CallContext = this.AdminClientRef.UserSendingEmails(searchCriteria,
                                                                               listSelectedIDs,
                                                                               sendMailData,
                                                                               this.CallContext);

                if (this.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
                {
                    ShowMSG(this.CallContext.Message);

                    RemoveModalWindow();

                    this.pnlSendEmail.Visible = false;
                }
                else
                {
                    ShowMSG(this.CallContext.Message);
                }
            }
            catch (Exception ex)
            {

                BaseHelper.Log("Грешка в btnSendEmails_Click " + formResource.PagePath);
                BaseHelper.Log(ex.Message);
                BaseHelper.Log(ex.StackTrace);
            }
        }
Beispiel #3
0
        public CallContext SendMailToAdministrator(SendMailHelper sendMailHelper)
        {
            CallContext callContext = new CallContext();



            SetDetaultKvParams(callContext);


            SendMailAction(GetSettingByCode(ETEMEnums.AppSettings.EmailForSending).SettingValue, GetSettingByCode(ETEMEnums.AppSettings.EmailForReciveError).SettingValue,
                sendMailHelper.SubjectBG, sendMailHelper.BodyBG, "Системен e-mail", new List<string>(), callContext, true);
            //
            return callContext;
        }