private Boolean SendConfirmationEmail()
        {
            bool blnEmailSent = false;

            try
            {

                //get managers info
                List<ManagerItem> staffMembers = null;
                if (clubItem.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                {
                    staffMembers = clubItem.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));

                    manager = staffMembers.First();
                }

                if (currentLanding != null && currentLanding.LandingBase.EmailTemplate.Item != null)
                {
                        //Get Campaign Email object
                    EmailBaseItem emailItem = currentLanding.LandingBase.EmailTemplate.Item;

                    Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                    urlOptions.AlwaysIncludeServerUrl = true;
                    urlOptions.AddAspxExtension = true;

                        //string strEmailSubject = campaign.CampaignBase.Emailsubject.Rendered;
                        string strEmailSubject = emailItem.Subject.Raw;
                        //string strEmailFromAddress = Settings.WebsiteMailFromText;
                        string strEmailFromAddress = emailItem.Fromaddress.Raw;
                        string strEmailToAddress = txtEmail.Value.Trim();

                        //Populate email text variables
                        Hashtable objTemplateVariables = new Hashtable();
                        objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage));
                        objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesAndClasses));
                        objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealth));
                        objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.Memberships));
                        objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy));
                        objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions));
                        objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved."));

                        //objTemplateVariables.Add("CampaignTermsAndConditionsLinkUrl", new PageSummaryItem(currentCampaign.CampaignBase.Termsandconditionslink.Item).QualifiedUrl);
                        objTemplateVariables.Add("CustomerName", txtName.Value.Trim());
                        if (manager != null)
                        {
                            objTemplateVariables.Add("ClubManagerName", manager.Person.Firstname.Rendered + " " + manager.Person.Lastname.Rendered);
                        }
                        else
                        {
                            objTemplateVariables.Add("ClubManagerName", "");
                        }
                        objTemplateVariables.Add("ClubName", clubItem.Clubname.Rendered);
                        objTemplateVariables.Add("EmailSubject", strEmailSubject);
                        objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                        objTemplateVariables.Add("EmailToAddress", strEmailToAddress);
                        objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl);
                        objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl);
                        objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl);
                        objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl);
                        objTemplateVariables.Add("ImageRootUrl", Sitecore.Web.WebUtil.GetServerUrl());
                        objTemplateVariables.Add("ClubPhoneNumber", clubItem.Salestelephonenumber.Rendered);
                        objTemplateVariables.Add("ClubHomePageUrl", Sitecore.Links.LinkManager.GetItemUrl(clubItem, urlOptions));

                        System.Text.StringBuilder markupBuilder;
                        markupBuilder = new System.Text.StringBuilder();

                        markupBuilder.Append(clubItem.Addressline1.Rendered);
                        markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline2.Rendered) ? "<br />" + clubItem.Addressline2.Rendered : "");
                        markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline3.Rendered) ? "<br />" + clubItem.Addressline3.Rendered : "");
                        markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline4.Rendered) ? "<br />" + clubItem.Addressline4.Rendered : "");
                        markupBuilder.Append("<br />" + clubItem.Postcode.Rendered);

                        objTemplateVariables.Add("ClubAddress", markupBuilder.ToString());

                        //Parser objParser = new Parser(campaign.CampaignBase.GetTemplateHtml(), objTemplateVariables);
                        Parser objParser = new Parser(objTemplateVariables);

                        if (emailItem.InnerItem.TemplateName == Templates.CampaignEmail)
                        {
                            CampaignEmailItem campaignEmail = (CampaignEmailItem)emailItem.InnerItem;
                            //First parse the Email Body text
                            objParser.SetTemplate(campaignEmail.Emailbody.Raw);
                            string strEmailBody = objParser.Parse();

                            objTemplateVariables.Add("EmailBody", strEmailBody);

                            //Second parse the full html -substituting in title and preheader
                            objTemplateVariables.Add("EmailTitle", campaignEmail.Emailtitle.Raw);
                            objTemplateVariables.Add("EmailPreheader", campaignEmail.Emailpreheader.Raw);

                            objParser = new Parser(objTemplateVariables);
                            if (clubItem.InnerItem.TemplateName == Templates.ClassicClub)
                            {
                                objParser.SetTemplate(campaignEmail.Classichtml.Raw);
                            }
                            else
                            {
                                objParser.SetTemplate(campaignEmail.Standardhtml.Raw);
                            }
                        }
                        else
                        {
                            EmailItem standardEmail = (EmailItem)emailItem.InnerItem;
                            //Standard email
                            objParser.SetTemplate(standardEmail.Emailhtml.Raw);
                        }
                        //Parser objParser = new Parser(Server.MapPath(EmailTemplates.FreeGuestPassConfirmation), objTemplateVariables);
                        string strEmailHtml = objParser.Parse();

                        mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                        mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                        string strAttachments = "";

                        //now call messaging service
                        objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strEmailHtml, strAttachments);

                        if (objSendResult.Success == true)
                        {
                            blnEmailSent = true;
                        }
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending module enquiry email confirmation {1}: {0}", ex.Message, clubItem.Clubname.Raw), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
        private Boolean SendConfirmationEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.EnquiryConfirmation;
                string strEmailFromAddress = Settings.WebsiteMailFromText;
                string strEmailToAddress = txtEmail.Value.Trim();

                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                urlOptions.AlwaysIncludeServerUrl = true;
                urlOptions.AddAspxExtension = true;
                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage));
                objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesLanding));
                objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealthArticles));
                objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.MembershipOptions));
                objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy));
                objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions));
                objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved."));
                objTemplateVariables.Add("CustomerName", txtName.Value.Trim());
                if (manager != null)
                {
                    objTemplateVariables.Add("ClubManagerName", manager.Person.Firstname.Rendered + " " + manager.Person.Lastname.Rendered);
                }
                else
                {
                    objTemplateVariables.Add("ClubManagerName", "");
                }
                objTemplateVariables.Add("ClubName", currentClub.Clubname.Rendered);
                objTemplateVariables.Add("ClubHomePageUrl", Sitecore.Links.LinkManager.GetItemUrl(currentClub, urlOptions));
                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);
                objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl);
                objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl);
                objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl);
                objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl);
                objTemplateVariables.Add("ImageRootUrl", WebUtil.GetServerUrl());
                objTemplateVariables.Add("ClubPhoneNumber", currentClub.Salestelephonenumber.Rendered);

                System.Text.StringBuilder markupBuilder;
                markupBuilder = new System.Text.StringBuilder();

                markupBuilder.Append(currentClub.Addressline1.Rendered);
                markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline2.Rendered) ? "<br />" + currentClub.Addressline2.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline3.Rendered) ? "<br />" + currentClub.Addressline3.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline4.Rendered) ? "<br />" + currentClub.Addressline4.Rendered : "");
                markupBuilder.Append("<br />" + currentClub.Postcode.Rendered);

                objTemplateVariables.Add("ClubAddress", markupBuilder.ToString());

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.EnquiryConfirmation), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.EnquiryConfirmation)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending confirmation email {1}: {0}", ex.Message, currentClub.Clubname.Raw), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
Esempio n. 3
0
        //protected void Application_Error(object sender, EventArgs e)
        //{
        //    // dont email error if HttpException or local copy
        //    //if (Server.GetLastError().GetType() != typeof(HttpException) && Request.Url.Host.ToLower() != "localhost")
        //    if (Request.Url.Host.ToLower() != "localhost")
        //    {
        //        Exception ex = Context.Error.GetBaseException();
        //    try
        //    {
        //        string strEmailSubject = EmailSubjects.CorporateEnquiryConfirmation;
        //        string strEmailFromAddress = Settings.WebsiteMailFromText;
        //        string strEmailToAddress = txtEmail.Value.Trim();
        //        //Populate email text variables
        //        Hashtable objTemplateVariables = new Hashtable();
        //        objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage));
        //        objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesAndClasses));
        //        objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealth));
        //        objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.Memberships));
        //        objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy));
        //        objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions));
        //        objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved."));
        //        objTemplateVariables.Add("CustomerName", txtName.Value.Trim());
        //        if (manager != null)
        //        {
        //            objTemplateVariables.Add("ClubManagerName", manager.Person.Firstname.Rendered + " " + manager.Person.Lastname.Rendered);
        //        }
        //        else
        //        {
        //            objTemplateVariables.Add("ClubManagerName", "");
        //        }
        //        objTemplateVariables.Add("ClubName", currentClub.Clubname.Rendered);
        //        objTemplateVariables.Add("EmailSubject", strEmailSubject);
        //        objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
        //        objTemplateVariables.Add("EmailToAddress", strEmailToAddress);
        //        objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl);
        //        objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl);
        //        objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl);
        //        objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl);
        //        objTemplateVariables.Add("ImageRootUrl", WebUtil.GetServerUrl());
        //        objTemplateVariables.Add("ClubPhoneNumber", currentClub.Salestelephonenumber.Rendered);
        //        System.Text.StringBuilder markupBuilder;
        //        markupBuilder = new System.Text.StringBuilder();
        //        markupBuilder.Append(currentClub.Addressline1.Rendered);
        //        markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline2.Rendered) ? "<br />" + currentClub.Addressline2.Rendered : "");
        //        markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline3.Rendered) ? "<br />" + currentClub.Addressline3.Rendered : "");
        //        markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline4.Rendered) ? "<br />" + currentClub.Addressline4.Rendered : "");
        //        markupBuilder.Append("<br />" + currentClub.Postcode.Rendered);
        //        objTemplateVariables.Add("ClubAddress", markupBuilder.ToString());
        //        //Parser objParser = new Parser(Server.MapPath(EmailTemplates.CorporateEnquiryConfirmation), objTemplateVariables);
        //        Parser objParser = new Parser(objTemplateVariables);
        //        objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.CorporateEnquiryConfirmation)).Emailhtml.Text);
        //        string strMessageBody = objParser.Parse();
        //        mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
        //        mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();
        //        string strAttachments = "";
        //        //now call messaging service
        //        objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments);
        //        if (objSendResult.Success == true)
        //        {
        //            blnEmailSent = true;
        //        }
        //}
        //        try
        //        {
        //            smtp.Send(msg);
        //        }
        //        catch (Exception expt) { }
        //    }
        //    //Server.ClearError();
        //}
        protected void Application_Error(object sender, EventArgs e)
        {
            try
            {
                HttpContext ctx = HttpContext.Current;

                Exception exception = ctx.Server.GetLastError();

                if (exception is ArgumentOutOfRangeException)
                {
                    // don't report these exceptions - they occur frequently in Sitecore when errorneous URLs are processed
                    return;
                }

                string errorEmail = Settings.SystemsErrorToMailNotification; // read the "To Email address" from config
                string strEmailToAddress = errorEmail;
                string strEmailFromAddress = Settings.SystemsErrorFromMailNotification;
                string strEmailSubject = EmailSubjects.AnyErrorNotification;

                if (!string.IsNullOrEmpty(strEmailToAddress))
                {
                    StringBuilder body = new StringBuilder();

                    body.Append("<b>Absolute Uri:</b><br />");
                    body.Append(string.Concat(Request.Url.AbsoluteUri, "<br />"));

                    body.Append("<b>Path and Query:</b><br />");
                    body.Append(string.Concat(Request.Url.PathAndQuery, "<br />"));

                    body.Append("<b>Sitecore Raw Url:</b><br />");
                    body.Append(string.Concat(Sitecore.Context.RawUrl, "<br />"));

                    body.Append("<b>Url:</b><br />");
                    body.Append(string.Format("{0}://{1}{2}<br />", Request.Url.Scheme, Request.Url.Host, Sitecore.Context.RawUrl));

                    body.Append("<b>User:</b><br />");
                    body.Append(Sitecore.Context.User.Name);

                    body.Append("<br />");

                    do
                    {
                        body.Append("<b>Message:</b><br />");
                        body.Append(string.Concat(exception.Message, "<br />"));
                        body.Append("<b>Stack Trace:</b><br />");
                        body.Append(string.Concat(exception.StackTrace, "<br />"));
                        body.Append("<b>Source:</b><br />");
                        body.Append(string.Concat(exception.Source, "<br /><br />"));
                        exception = exception.InnerException;
                    } while (exception != null);

                    string strMessageBody = Convert.ToString(body);

                    mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                    mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                    string strAttachments = "";

                    //now call messaging service
                    //objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments);

                    if (objSendResult.Success == false)
                    {
                        Log.Error(String.Format("Error sending notification email"), this);
                    }

                    using (System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(strEmailFromAddress, strEmailToAddress))
                    {
                        message.Subject = strEmailSubject;
                        message.IsBodyHtml = true;
                        message.Priority = MailPriority.High;
                        message.Body = strMessageBody;
                        Sitecore.MainUtil.SendMail(message);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        private Boolean SendAdminEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.FeedbackCampaignFormAdmin;
                string strEmailFromAddress = Settings.WebsiteMailFromText;

                string strEmailToAddress = "";
                string strEmailBccAddress = "";
                if (Sitecore.Configuration.Settings.GetSetting("SystemEmails").ToLower() == "false")
                {
                    strEmailToAddress = Settings.McCormackMorrisonTestEmailAddress;
                }
                else
                {
                    //form sent to webleads -send confirmation to admin team
                    strEmailToAddress = Settings.FeedbackCampaignEmailToListShort;
                }

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("CustomerName", txtName.Value);
                objTemplateVariables.Add("CustomerEmail", txtEmail.Value);
                objTemplateVariables.Add("HomeClubID", clubItem.ClubId.Rendered);
                objTemplateVariables.Add("ClubName", clubItem.Clubname.Rendered);
                objTemplateVariables.Add("Telephone", txtPhone.Value);
                objTemplateVariables.Add("Comments", "N/A");
                objTemplateVariables.Add("HowDidCustomerFindUs", "N/A"); //drpHowDidYouFindUs.SelectedValue.ToString() != "" && drpHowDidYouFindUs.SelectedValue.ToString() != Translate.Text("Select") ? drpHowDidYouFindUs.SelectedValue.ToString() : "");
                objTemplateVariables.Add("SubscribeToNewsletter", chkSubscribe.Checked ? "Yes" : "No");
                objTemplateVariables.Add("PublishDetails", "N/A");
                objTemplateVariables.Add("FeedbackSubject", currentLanding.LandingBase.LandingId.Rendered); //currentCampaign.CampaignBase.Campaigntype.Raw);
                objTemplateVariables.Add("FeedbackSubjectDetail", currentLanding.DisplayName); //currentCampaign.CampaignBase.Campaignname.Rendered);
                objTemplateVariables.Add("SubmissionDate", DateTime.Now.ToShortDateString());
                objTemplateVariables.Add("ImageSubmitted", "N/A");
                objTemplateVariables.Add("EnquiryType", "General");

                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.FeedbackCampaignFormAdmin), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.FeedbackCampaignFormAdmin)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", strEmailBccAddress, strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending club feedback data email: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
        private Boolean SendConfirmationEmail()
        {
            bool blnEmailSent = false;
            bool blnIsAppointment = false;

            try
            {
                if(txtPreferredDay.Value.Trim() != "" && drpTreatment.SelectedValue.ToString() != "" && drpTreatment.SelectedValue.ToString() != Translate.Text("Select"))
                {
                    blnIsAppointment = true;
                }
                string strEmailSubject = blnIsAppointment ? EmailSubjects.HealthAndBeautyAppointmentConfirmation : EmailSubjects.HealthAndBeautyEnquiryConfirmation;
                //string strEmailTemplate = blnIsAppointment ? EmailTemplates.HealthAndBeautyAppointmentConfirmation : EmailTemplates.HealthAndBeautyEnquiryConfirmation;
                EmailItem EmailTemplate = blnIsAppointment ? (EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.HealthAndBeautyAppointmentConfirmation) : (EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.HealthAndBeautyEnquiryConfirmation);

                string strEmailFromAddress = Settings.WebsiteMailFromText;
                string strEmailToAddress = txtEmail.Value.Trim();

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage));
                objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesAndClasses));
                objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealth));
                objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.Memberships));
                objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy));
                objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions));
                objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved."));
                objTemplateVariables.Add("CustomerName", txtName.Value.Trim());
                if (clubManager != null)
                {
                    objTemplateVariables.Add("ClubManagerName", clubManager.Person.Firstname.Rendered + " " + clubManager.Person.Lastname.Rendered);
                }
                else
                {
                    objTemplateVariables.Add("ClubManagerName", "");
                }
                objTemplateVariables.Add("PreferredDay", txtPreferredDay.Value.Trim() != "" ? txtPreferredDay.Value.Trim() : "N/A");
                objTemplateVariables.Add("PreferredTime", drpPreferredTime.SelectedValue.ToString() != "" && drpPreferredTime.SelectedValue.ToString() != Translate.Text("Select") ? drpPreferredTime.SelectedValue.ToString() : "N/A");
                objTemplateVariables.Add("Treatment", drpTreatment.SelectedValue.ToString() != "" && drpTreatment.SelectedValue.ToString() != Translate.Text("Select") ? drpTreatment.SelectedValue.ToString() : "N/A");
                objTemplateVariables.Add("ClubName", club.Clubname.Rendered);
                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);
                objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl);
                objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl);
                objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl);
                objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl);
                objTemplateVariables.Add("ImageRootUrl", Sitecore.Web.WebUtil.GetServerUrl());
                objTemplateVariables.Add("ClubPhoneNumber", club.Salestelephonenumber.Rendered);

                System.Text.StringBuilder markupBuilder;
                markupBuilder = new System.Text.StringBuilder();

                markupBuilder.Append(club.Addressline1.Rendered);
                markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline2.Rendered) ? "<br />" + club.Addressline2.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline3.Rendered) ? "<br />" + club.Addressline3.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline4.Rendered) ? "<br />" + club.Addressline4.Rendered : "");
                markupBuilder.Append("<br />" + club.Postcode.Rendered);

                objTemplateVariables.Add("ClubAddress", markupBuilder.ToString());

                //Get the facility modules that are to be shown on listing page
                List<TreatmentModuleItem> treatmentModules = listing.Sharedtreatments.ListItems.ToList().ConvertAll(X => new TreatmentModuleItem(X));

                //Chosen Treatment and Brand details
                string strTreatment = "";
                string strHealthAndBeautyBrand = "";
                string strTreatmentBrandDetails = "";

                strTreatment = drpTreatment.SelectedValue.ToString() != Translate.Text("Select") ? drpTreatment.SelectedValue.ToString() : "";

                foreach (TreatmentModuleItem module in treatmentModules)
                {
                    //find which brand the treatment belows to
                    sharedLanding = new HealthAndBeautyLandingItem(module.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", HealthAndBeautyLandingItem.TemplateId)));
                    if (sharedLanding != null)
                    {
                        strHealthAndBeautyBrand = sharedLanding.PageSummary.NavigationTitle.Rendered;
                        strEmailSubject = strEmailSubject.Replace("<SpaName>", strHealthAndBeautyBrand);
                    }
                    break;
                }

                if (strTreatment != "" && strHealthAndBeautyBrand != "" && blnIsAppointment)
                {
                    strTreatmentBrandDetails = strTreatment + " at " + strHealthAndBeautyBrand + ", " + club.Clubname.Rendered;
                }
                else if (strHealthAndBeautyBrand != "")
                {
                    strTreatmentBrandDetails = strHealthAndBeautyBrand + ", " + club.Clubname.Rendered;
                }
                else if (strTreatment != "")
                {
                    strTreatmentBrandDetails = strHealthAndBeautyBrand + ", " + club.Clubname.Rendered;
                }
                else
                {
                    strTreatmentBrandDetails = club.Clubname.Rendered;
                }

                objTemplateVariables.Add("TreatmentBrandDetails", strTreatmentBrandDetails);

                //Chosen Time and Day options
                string strDay = txtPreferredDay.Value.Trim();
                string strTime = drpPreferredTime.SelectedValue.ToString() != Translate.Text("Select") ? drpPreferredTime.SelectedValue.ToString() : "";
                string strDayAndTime = "";

                if (strDay != "" && strTime != "")
                {
                    strDayAndTime = strDay + " and " + strTime;
                }
                else if (strDay != "")
                {
                    strDayAndTime = strDay;
                }

                objTemplateVariables.Add("PreferredDayAndTime", strDayAndTime);

                //Parser objParser = new Parser(Server.MapPath(strEmailTemplate), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(EmailTemplate.Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending confirmation email {1}: {0}", ex.Message, club.Clubname.Raw), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
        private Boolean SendAdminEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.KidsClubFeedbackFormAdmin;
                string strEmailFromAddress = Settings.WebsiteMailFromText;

                string strEmailToAddress = "";
                if (Sitecore.Configuration.Settings.GetSetting("SystemEmails").ToLower() == "false")
                {
                    //Use test
                    strEmailToAddress = Settings.McCormackMorrisonTestEmailAddress;
                }
                else
                {
                    if (currentClub.Kidsfeedbackemail.Rendered.Trim() != "")
                    {
                        strEmailToAddress = currentClub.Kidsfeedbackemail.Rendered.Trim();
                    }
                    else if (currentClub.Salesemail.Rendered.Trim() != "")
                    {
                        strEmailToAddress = currentClub.Salesemail.Rendered.Trim();
                    }
                    else
                    {
                        strEmailToAddress = Settings.DefaultFormToEmailAddress;
                        //TODO: Send warning alert.
                        Log.Error(String.Format("Could not find sales email address for club {0}", currentClub.Clubname.Raw), this);
                    }
                }

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("CustomerName", txtName.Value.Trim());
                objTemplateVariables.Add("CustomerEmail", txtEmail.Value.Trim());
                objTemplateVariables.Add("MembershipNo", txtMembership.Value.Trim());
                objTemplateVariables.Add("Telephone", txtPhone.Value.Trim());
                objTemplateVariables.Add("QueryType", drpQueryTypeList.SelectedValue.ToString() != Translate.Text("Select") ? drpQueryTypeList.SelectedValue.ToString() : "");
                objTemplateVariables.Add("Comments", txtComments.Value.Trim());
                objTemplateVariables.Add("ClubName", currentClub.Clubname.Rendered);
                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.KidsClubFeedbackFormAdmin), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.KidsClubFeedbackFormAdmin)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments);

                if (currentClub.ClubId.Rendered == "")
                {
                    Log.Error(String.Format("No Club ID exists for club: {0}", currentClub.Clubname.Raw), this);
                }

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending kids club feedback data email {1}: {0}", ex.Message, currentClub.Clubname.Raw), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
        private Boolean SendAdminEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.PersonalDetailsFormAdmin;
                string strEmailFromAddress = Settings.WebsiteMailFromText;

                string strEmailToAddress = "";
                if (Sitecore.Configuration.Settings.GetSetting("SystemEmails").ToLower() == "false")
                {
                    //Use test
                    strEmailToAddress = Settings.McCormackMorrisonTestEmailAddress;
                }
                else
                {
                    //Use Email Address for per marketing campaigns
                    strEmailToAddress = Settings.FeedbackCampaignEmailToListShort;
                }

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                //objTemplateVariables.Add("FeedbackSubject", "Personal Details Update");
                //objTemplateVariables.Add("FeedbackSubjectDetail", "");
                objTemplateVariables.Add("SubmissionDate", DateTime.Now.ToShortDateString());
                objTemplateVariables.Add("MemberRecordID", hdnRecordId.Value.Trim());
                objTemplateVariables.Add("CustomerName", (txtFirstName.Value.Trim() + " " + txtSurname.Value.Trim()).Trim());
                objTemplateVariables.Add("CustomerEmail", txtEmail.Value.Trim());
                objTemplateVariables.Add("MembershipNo", txtMembership.Value.Trim());

                DateTime datDateOfBirth;
                if (DateTime.TryParse(drpDOBDay.SelectedValue + "/" + drpDOBMonth.SelectedValue + "/" + drpDOBYear.SelectedValue, out datDateOfBirth))
                {
                    objTemplateVariables.Add("DateOfBirth", datDateOfBirth.ToString("dd/MM/yyyy"));
                }
                else
                {
                    objTemplateVariables.Add("DateOfBirth", "");
                }

                objTemplateVariables.Add("HomePhoneNo", txtHomeNo.Value.Trim());
                objTemplateVariables.Add("WorkPhoneNo", txtWorkNo.Value.Trim());
                objTemplateVariables.Add("MobilePhoneNo", txtMobileNo.Value.Trim());

                objTemplateVariables.Add("Address1", txtAddress1.Value.Trim());
                objTemplateVariables.Add("Address2", txtAddress2.Value.Trim());
                objTemplateVariables.Add("Address3", txtAddress3.Value.Trim());
                objTemplateVariables.Add("Address4", txtAddress4.Value.Trim());
                objTemplateVariables.Add("Address5", txtAddress5.Value.Trim());
                objTemplateVariables.Add("Postcode", txtPostcode.Value.Trim());

                objTemplateVariables.Add("ContactByMarketing", chkContactByMarketing.Checked == true ? "Y" : "N");

                objTemplateVariables.Add("SubscribeToNewsletter", "N/A");
                objTemplateVariables.Add("PublishDetails", "N/A");

                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.ClubFeedbackFormAdmin), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.PersonalDetailsFormAdmin)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", "", strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending contact us data email: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
        private Boolean SendConfirmationEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.PersonalDetailsConfirmation;
                string strEmailFromAddress = Settings.WebsiteMailFromText;
                string strEmailToAddress = txtEmail.Value.Trim();

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage));
                objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesAndClasses));
                objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealth));
                objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.Memberships));
                objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy));
                objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions));
                objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved."));
                objTemplateVariables.Add("CustomerName", (txtFirstName.Value.Trim() + " " + txtSurname.Value.Trim()).Trim());

                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);
                objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl);
                objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl);
                objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl);
                objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl);
                objTemplateVariables.Add("ImageRootUrl", Sitecore.Web.WebUtil.GetServerUrl());

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.ContactUsFeedbackConfirmation), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.PersonalDetailsConfirmation)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending contact us email confirmation: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
        private Boolean SendConfirmationEmail()
        {
            bool blnEmailSent = false;

            try
            {
                if (campaign.CampaignBase.Emailtemplate.Item != null)
                {
                    //Get Campaign Email object
                    EmailBaseItem emailItem = campaign.CampaignBase.Emailtemplate.Item;

                    //string strEmailSubject = campaign.Campaign.CampaignBase.Emailsubject.Rendered;
                    string strEmailSubject = emailItem.Subject.Raw;
                    //string strEmailFromAddress = Settings.WebsiteMailFromText;
                    string strEmailFromAddress = emailItem.Fromaddress.Raw;
                    string strEmailToAddress = email.Value.Trim();

                    //Populate email text variables
                    Hashtable objTemplateVariables = new Hashtable();
                    objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage));
                    objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved."));
                    objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesAndClasses));
                    objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealth));
                    objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.Memberships));
                    objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy));
                    objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions));
                    //objTemplateVariables.Add("CampaignTermsAndConditionsLinkUrl", new PageSummaryItem(campaign.CampaignBase.Termsandconditionslink.Item).QualifiedUrl);
                    objTemplateVariables.Add("CampaignUrl", campaign.CampaignBase.QualifiedUrl);

                    objTemplateVariables.Add("ClubManagerName", manager != null ? manager.Person.Firstname.Rendered + " " + manager.Person.Lastname.Rendered : "");

                    objTemplateVariables.Add("EmailSubject", strEmailSubject);
                    objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                    objTemplateVariables.Add("EmailToAddress", strEmailToAddress);
                    objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl);
                    objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl);
                    objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl);
                    objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl);
                    objTemplateVariables.Add("ImageRootUrl", Sitecore.Web.WebUtil.GetServerUrl());

                    System.Text.StringBuilder markupBuilder;
                    markupBuilder = new System.Text.StringBuilder();

                    //Parser objParser = new Parser(campaign.Campaign.CampaignBase.GetTemplateHtml(), objTemplateVariables);
                    Parser objParser = new Parser(objTemplateVariables);
                    if (emailItem.InnerItem.TemplateName == Templates.CampaignEmail)
                    {
                        CampaignEmailItem campaignEmail = (CampaignEmailItem)emailItem.InnerItem;
                        //First parse the Email Body text
                        objParser.SetTemplate(campaignEmail.Emailbody.Raw);
                        string strEmailBody = objParser.Parse();

                        objTemplateVariables.Add("EmailBody", strEmailBody);

                        //Second parse the full html -substituting in title and preheader
                        objTemplateVariables.Add("EmailTitle", campaignEmail.Emailtitle.Raw);
                        objTemplateVariables.Add("EmailPreheader", campaignEmail.Emailpreheader.Raw);

                        objParser = new Parser(objTemplateVariables);
                        objParser.SetTemplate(campaignEmail.Classichtml.Raw);
                    }
                    else
                    {
                        EmailItem standardEmail = (EmailItem)emailItem.InnerItem;
                        //Standard email
                        objParser.SetTemplate(standardEmail.Emailhtml.Raw);
                    }
                    //Parser objParser = new Parser(Server.MapPath(EmailTemplates.FreeGuestPassConfirmation), objTemplateVariables);
                    string strEmailHtml = objParser.Parse();

                    mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                    mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                    string strAttachments = "";

                    //now call messaging service
                    objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strEmailHtml, strAttachments);

                    if (objSendResult.Success == true)
                    {
                        blnEmailSent = true;
                    }
                }

            }
            catch (Exception ex)
            {
                //Log.Error(String.Format("Error sending contact us email confirmation {1}: {0}", ex.Message, currentClub.Clubname.Raw), this);
            }

            return blnEmailSent;
        }
        private Boolean SendAdminEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.FeedbackCampaignFormAdmin;
                string strEmailFromAddress = Settings.WebsiteMailFromText;

                string strEmailToAddress = "";
                if (Sitecore.Configuration.Settings.GetSetting("SystemEmails").ToLower() == "false")
                {
                    //Use test
                    strEmailToAddress = Settings.McCormackMorrisonTestEmailAddress;
                }
                else
                {
                    strEmailToAddress = Settings.FeedbackCampaignEmailToListShort;
                }

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("CustomerEmail", email.Value);
                //objTemplateVariables.Add("HomeClubID", txtClubCode.Value);
                objTemplateVariables.Add("Comments", "N/A");
                objTemplateVariables.Add("SubscribeToNewsletter", "Yes");
                objTemplateVariables.Add("PublishDetails", "N/A");
                objTemplateVariables.Add("FeedbackSubject", campaign.CampaignBase.Campaigntype.Raw);
                objTemplateVariables.Add("FeedbackSubjectDetail", campaign.CampaignBase.Campaignname.Rendered);
                objTemplateVariables.Add("SubmissionDate", DateTime.Now.ToShortDateString());
                objTemplateVariables.Add("ImageSubmitted", "N/A");

                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.FeedbackCampaignFormAdmin), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(campaign.CampaignBase.GetAdminTemplateHtml());

                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", "", strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending club feedback data email: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
Esempio n. 11
0
        private Boolean SendAdminEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.FeedbackCampaignFormAdmin;
                string strEmailFromAddress = Settings.WebsiteMailFromText;

                string strEmailToAddress = "";
                if (Sitecore.Configuration.Settings.GetSetting("SystemEmails").ToLower() == "false")
                {
                    //Use test
                    strEmailToAddress = Settings.McCormackMorrisonTestEmailAddress;
                }
                else
                {
                    strEmailToAddress = Settings.FeedbackCampaignEmailToListShort;
                }

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("CustomerName", yourname.Value);
                objTemplateVariables.Add("CustomerEmail", email.Value);
                //objTemplateVariables.Add("HomeClubID", txtClubCode.Value);
                objTemplateVariables.Add("HomeClubID", currentClub.ClubId.Rendered);
                objTemplateVariables.Add("Telephone", contact.Value);
                objTemplateVariables.Add("Comments", "N/A");
                objTemplateVariables.Add("SubscribeToNewsletter", subscribe.Checked ? "Yes" : "No");
                objTemplateVariables.Add("PublishDetails", "N/A");
                //objTemplateVariables.Add("FeedbackSubject", campaign.CampaignBase.Campaigntype.Raw);
                objTemplateVariables.Add("FeedbackSubject", !String.IsNullOrEmpty(campaign.CampaignBase.Campaigntype.Raw) ? campaign.CampaignBase.Campaigntype.Raw : "");
                objTemplateVariables.Add("FeedbackSubjectDetail", campaign.CampaignBase.Campaignname.Rendered);
                objTemplateVariables.Add("SubmissionDate", DateTime.Now.ToShortDateString());
                objTemplateVariables.Add("ImageSubmitted", "N/A");

                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.FeedbackCampaignFormAdmin), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.FeedbackCampaignFormAdmin)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", "", strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    if (campaign.InnerItem.TemplateName == Templates.ExMemberCampaign)
                    {
                        //if this is an Ex-Member send email to Members Feeback email address for the club

                        strEmailToAddress = "";
                        if (Sitecore.Configuration.Settings.GetSetting("SystemEmails").ToLower() == "false")
                        {
                            //Use test
                            strEmailToAddress = Settings.McCormackMorrisonTestEmailAddress;
                        }
                        else
                        {
                            //use feedback email address
                            strEmailToAddress = currentClub.Feedbackemail.Raw;
                        }

                        //now call messaging service
                        objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", "", strEmailSubject, true, strMessageBody, strAttachments);

                    }

                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending club feedback data email: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
Esempio n. 12
0
        private Boolean SendAdminEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.ClubEnquiryFormAdmin;
                string strEmailFromAddress = Settings.WebsiteMailFromText;

                string strEmailToAddress = "";
                if (Sitecore.Configuration.Settings.GetSetting("SystemEmails").ToLower() == "false")
                {
                    //Use test
                    strEmailToAddress = Settings.McCormackMorrisonTestEmailAddress;
                }
                else
                {
                    if (currentClub.Salesemail.Rendered.Trim() != "")
                    {
                        strEmailToAddress = currentClub.Salesemail.Rendered.Trim();
                    }
                    else
                    {
                        strEmailToAddress = Settings.DefaultFormToEmailAddress;
                        //TODO: Send warning alert.
                        Log.Error(String.Format("Could not find sales email address for club {0}", currentClub.Clubname.Raw), this);
                    }
                }

                User objUser = new User();
                //Set user session variable
                if (Session["sess_User"] != null)
                {
                    objUser = (User)Session["sess_User"];
                }

                string enquiryFormType = "";
                switch (objUser.EnquiryFormType)
                {
                    case EnquiryFormTypes.BookATour:
                        enquiryFormType = "Book A Visit";
                        break;
                    case EnquiryFormTypes.Corporate:
                        enquiryFormType = "Corporate";
                        break;
                    case EnquiryFormTypes.ExistingScheme:
                        enquiryFormType = "Existing Scheme";
                        break;
                    case EnquiryFormTypes.General:
                        enquiryFormType = "General";
                        break;
                    default:
                        enquiryFormType = "General";
                        break;
                }

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("CustomerName", txtName.Value.Trim());
                objTemplateVariables.Add("CustomerEmail", txtEmail.Value.Trim());
                objTemplateVariables.Add("Telephone", txtPhone.Value.Trim() != "" ? txtPhone.Value.Trim() : "N/A");
                objTemplateVariables.Add("HowDidCustomerFindUs", drpHowDidYouFindUs.SelectedValue.ToString() != "" && drpHowDidYouFindUs.SelectedValue.ToString() != Translate.Text("Select") ? drpHowDidYouFindUs.SelectedValue.ToString() : "");
                objTemplateVariables.Add("SubscribeToNewsletter", chkSubscribe.Checked ? "Yes" : "No");
                objTemplateVariables.Add("ClubName", currentClub.Clubname.Rendered);
                objTemplateVariables.Add("EnquiryType", enquiryFormType);
                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.ClubEnquiryFormAdmin), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.ClubEnquiryFormAdmin)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

                if (currentClub.ClubId.Rendered == "")
                {
                    Log.Error(String.Format("No Club ID exists for club: {0}", currentClub.Clubname.Raw), this);
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending enquiry data email {1}: {0}", ex.Message, currentClub.Clubname.Raw), this);
            }

            return blnEmailSent;
        }
        private Boolean SendAdminEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.FeedbackCampaignFormAdmin;
                string strEmailFromAddress = Settings.WebsiteMailFromText;

                string strEmailToAddress = "";
                string strEmailBccAddress = "";
                if (Sitecore.Configuration.Settings.GetSetting("SystemEmails").ToLower() == "false")
                {
                    strEmailToAddress = Settings.McCormackMorrisonTestEmailAddress;
                }
                else
                {
                    //Use live emails
                    if (chkExistingMember.Checked == false && campaign.CampaignBase.Isweblead.Checked == true)
                    {
                        //form sent to webleads -send confirmation to admin team
                        strEmailToAddress = Settings.FeedbackCampaignEmailToListShort;
                    }
                    else
                    {
                        //form NOT sent to webleads -send directly to club
                        strEmailToAddress = campaign.CampaignBase.Administratorsemaillist.Raw;
                        //Bcc admin personnel
                        strEmailBccAddress = Settings.FeedbackCampaignEmailToListShort;
                    }
                }

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("CustomerName", name.Value);
                objTemplateVariables.Add("CustomerEmail", email.Value);
                objTemplateVariables.Add("HomeClubID", currentClub.ClubId.Rendered);
                objTemplateVariables.Add("Telephone", tel.Value);
                objTemplateVariables.Add("ExistingMember", chkExistingMember.Checked == true ? "Y" : "N");
                objTemplateVariables.Add("Comments", "N/A");
                objTemplateVariables.Add("SubscribeToNewsletter", "N/A");
                objTemplateVariables.Add("PublishDetails", "N/A");
                objTemplateVariables.Add("FeedbackSubject", campaign.CampaignBase.Campaigntype.Raw);
                objTemplateVariables.Add("FeedbackSubjectDetail", campaign.CampaignBase.Campaignname.Rendered);
                objTemplateVariables.Add("SubmissionDate", DateTime.Now.ToShortDateString());
                objTemplateVariables.Add("ImageSubmitted", "N/A");

                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.FeedbackCampaignFormAdmin), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.FeedbackCampaignFormAdmin)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", strEmailBccAddress, strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending club feedback data email: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }