Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int count = 0;
                List<object> list = gridContacts.GetSelectedFieldValues("BusinessEntityId");
                foreach (int item in list)
                {
                    var person = (from x in Persons where x.BusinessEntityId == item select x).FirstOrDefault();
                    if (person == null) continue;
                    if (person.Email.Trim() == "") continue;
                    CommonWeb.EmailManagement.EmailSenderEventArgs args = new CommonWeb.EmailManagement.EmailSenderEventArgs();
                    args.EmailType = EmailManager.EmailTypes.Custom;
                    args.CurrentPerson = person;
                    args.EmailTitle = txtSubject.Text;
                    args.InputObject = EmailContentHtmlEditor.Html;
                    args.CurrentPage = this.Page;
                    //TOOD: Conference Default Managemenet
                    //args.LanguageId = ConferenceBasePage.GetCurrentPageLanguageId(this.Page);
                    //args.CurrentConference = Code.RbmCommon.ConferenceBasePage.GetConferenceFromPage(this.Page);

                    args.ToUser = person.EmailAddressPrimaryObject.Email;
                    manager.OnSendEmail(args);
                    count++;
                }
                string[] emailsSplit = txtEmail.Text.Split(',');
                foreach (string email in emailsSplit)
                {
                    if (string.IsNullOrEmpty(email.Trim())) continue;
                    string template = EmailManager.GetTemplateClearCustomData(EmailContentHtmlEditor.Html);
                    EmailManager.sendMail(template, txtSubject.Text, email);
                    count++;
                }

                //TODO: Conference Send Email Success
                //SuccessMessage.Visible = true;
                string MessageText = "Email Sent Successfully To " + count.ToString() + " Accounts";
                //SuccessMessage.InnerText = MessageText.Replace("##COUNT##", );

                    NotifyMessage(NotifyMessageType.Success, MessageText);
            }
            catch (Exception ex)
            {
                NotifyMessage(NotifyMessageType.Error, ex.Message);
            }
        }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int count = 0;
                List<object> list = gridContacts.GetSelectedFieldValues("BusinessEntityId");
                foreach (int item in list)
                {
                    var person = (from x in Persons where x.BusinessEntityId == item select x).FirstOrDefault();
                    if (person == null) continue;
                    if (person.Email.Trim() == "") continue;
                    CommonWeb.EmailManagement.EmailSenderEventArgs args = new CommonWeb.EmailManagement.EmailSenderEventArgs();
                    args.EmailType = EmailManager.EmailTypes.Custom;
                    args.CurrentPerson = person;
                    args.EmailTitle = txtSubject.Text;
                    args.InputObject = EmailContentHtmlEditor.Html;
                    args.CurrentPage = this.Page;
                    //TOOD: Conference Default Managemenet
                    //args.LanguageId = ConferenceBasePage.GetCurrentPageLanguageId(this.Page);
                    //args.CurrentConference = Code.RbmCommon.ConferenceBasePage.GetConferenceFromPage(this.Page);

                    args.ToUser = person.EmailAddressPrimaryObject.Email;
                    manager.OnSendEmail(args);
                    count++;
                }
                string[] emailsSplit = txtEmail.Text.Split(',');
                foreach (string email in emailsSplit)
                {
                    if (string.IsNullOrEmpty(email.Trim())) continue;
                    string template = EmailManager.GetTemplateClearCustomData(EmailContentHtmlEditor.Html);
                    EmailManager.sendMail(template, txtSubject.Text, email);
                    count++;
                }

                Session["Notification"] = "success";
                Response.Redirect("~/g/Content/Email/Send.aspx");
            }
            catch (Exception ex)
            {
                SetNotification("fail", ex.Message, "", this);
            }
        }
Esempio n. 3
0
 private string GetTemplateUserData(string template, EmailSenderEventArgs e)
 {
     if (e.CurrentPerson != null)
     {
         #region Template User
         template = template.Replace("##DATE##", DateTime.Now.ToLongDateString());
         template = template.Replace("##CITY##", e.CurrentPerson.MainPersonAddress.City);
         template = template.Replace("##COUNTRY##", e.CurrentPerson.MainPersonAddress.CountryName);
         template = template.Replace("##PHONENUMBER##", e.CurrentPerson.PersonHomePhoneMain);
         template = template.Replace("##MOBILE##", e.CurrentPerson.PersonMobileMain);
         // replace ##xxx## with appropriate values
         template = template.Replace("##NAME##", e.CurrentPerson.DisplayName);
         template = template.Replace("##NAMEFULL##", e.CurrentPerson.FullName);
         template = template.Replace("##USERNAME##", e.CurrentPerson.UserName);
         //input object in signup email is password
         template = template.Replace("##PASSWORD##", e.InputObject == null ? string.Empty : e.InputObject.ToString());
         template = template.Replace("##VERIFY##", e.CurrentPerson.Credentials.ActivationCode);
         #endregion
     }
     return template;
 }
Esempio n. 4
0
 private string GetTemplateCustomData(string template, EmailSenderEventArgs e)
 {
     if (e.CurrentPerson != null)
     {
         #region Template User
         template = template.Replace("##DATE##", DateTime.Now.ToLongDateString());
         template = template.Replace("##CITY##", e.CurrentPerson.MainPersonAddress.City);
         template = template.Replace("##COUNTRY##", e.CurrentPerson.MainPersonAddress.CountryName);
         template = template.Replace("##PHONENUMBER##", e.CurrentPerson.PersonHomePhoneMain);
         template = template.Replace("##MOBILE##", e.CurrentPerson.PersonMobileMain);
         // replace ##xxx## with appropriate values
         template = template.Replace("##NAME##", e.CurrentPerson.DisplayName);
         template = template.Replace("##NAMEFULL##", e.CurrentPerson.FullName);
         template = template.Replace("##USERNAME##", e.CurrentPerson.UserName);
         #endregion
     }
     return template;
 }
Esempio n. 5
0
 private string GetTemplateAbstractData(string tmpl, EmailSenderEventArgs e)
 {
     if (e.CurrentAbstract != null)
     {
         tmpl = tmpl.Replace("##DATE##", DateTime.Now.ToLongDateString());
         tmpl = tmpl.Replace("##CITY##", e.CurrentAbstract.MainAuthor.City);
         tmpl = tmpl.Replace("##COUNTRY##", e.CurrentAbstract.MainAuthor.Country);
         tmpl = tmpl.Replace("##PHONENUMBER##", String.Format("{0} - {1}", e.CurrentAbstract.MainAuthor.PhoneNumberAreaCode, e.CurrentAbstract.MainAuthor.PhoneNumber));
         // replace ##xxx## with appropriate values
         tmpl = tmpl.Replace("##NAME##", e.CurrentAbstract.AuthorContactName);
         tmpl = tmpl.Replace("##NAMEFULL##", e.CurrentAbstract.AuthorContactNameFull);
         tmpl = tmpl.Replace("##TITLE##", e.CurrentAbstract.AbstractTitle);
         tmpl = tmpl.Replace("##ABSTRACTNUMBER##", e.CurrentAbstract.ABCode);
         tmpl = tmpl.Replace("##CATEGORY##", e.CurrentAbstract.CurrentConferenceCategory.CategoryName);
         tmpl = tmpl.Replace("##AUTHORS##", e.CurrentAbstract.AbstractAuthors);
     }
     return tmpl;
 }
Esempio n. 6
0
        public bool SendEmail(object sender, EmailSenderEventArgs e)
        {
            bool result = false;
            string template = string.Empty;
            string title = string.Empty;
            if (e.CurrentConference == null) return result;
            if (e.EmailType != EmailTypes.Custom)
            {
                BusinessLogicLayer.Entities.Conference.EmailTemplate emailTemplate = new BusinessLogicLayer.Components.Conference.EmailTemplateLogic().GetTemplate((int)e.EmailType, e.CurrentConference.ConferenceId, e.LanguageId);

                if (emailTemplate == null) return result;

                template = emailTemplate.EmailContent;
                title = emailTemplate.Name;
                switch (e.EmailType)
                {
                    case EmailTypes.Signup:
                        template = GetTemplateUserData(template, e);
                        break;
                    case EmailTypes.Register:
                        template = GetTemplateUserData(template, e);
                        break;
                    case EmailTypes.AdminEmailGeneralTemplate:
                        template = template.Replace("##CUSTOMBODY##", e.InputObject == null ? string.Empty : e.InputObject.ToString());
                        break;
                    case EmailTypes.UserEmailGeneralTemplate:
                        template = template.Replace("##CUSTOMBODY##", e.InputObject == null ? string.Empty : e.InputObject.ToString());
                        break;
                    case EmailTypes.ForgotPassword:
                        template = GetTemplateUserData(template, e);
                        break;
                    case EmailTypes.AbstractCancelled:
                    case EmailTypes.AbstractEdited:
                    case EmailTypes.AbstractOralAccepted:
                    case EmailTypes.AbstractPosterAccepted:
                    case EmailTypes.AbstractRejected:
                    case EmailTypes.AbstractRequireRevise:
                    case EmailTypes.AbstractReviewed:
                    case EmailTypes.AbstractSubmitted:
                    case EmailTypes.AbstractWaitingReview:
                        template = GetTemplateAbstractData(template, e);
                        break;
                    default:
                        return result;
                }
            }
            else
            {
                template = GetTemplateCustomData(e.InputObject.ToString(), e);
                title = e.EmailTitle;
            }
            result = sendMailNew(template, title, e.ToUser, e.CurrentPage, e.FileAttachment, e.FileMemoryStream);
            return result;
        }
Esempio n. 7
0
 public void OnSendEmail(EmailSenderEventArgs e)
 {
     if (SendEmailEvent != null)
         SendEmailEvent(this, e);
 }