/// <summary>
        /// Method to get the subject line based on the page to be emailed
        /// </summary>
        /// <param name="objEmailInfo">Email link entity containing Type</param>
        /// <returns>Subject in string format.</returns>
        private string GetMessageSubject(EmailLink objEmailInfo)
        {
            StringBuilder sbEmailSubject = new StringBuilder();

            sbEmailSubject.Append(objEmailInfo.FromUserName);
            if (objEmailInfo.TypeName == "GuestBook")
                sbEmailSubject.Append(" wants you to read a guestbook on Your Tribute..." + "<br/>");
            else
                sbEmailSubject.Append(" wants you to view a Tribute");

            return sbEmailSubject.ToString();
        }
        /// <summary>
        /// Method to send email to the list of users
        /// </summary>
        /// <param name="objUsers">EmailLink entity containing User name and email address</param>
        public void SendEmail(EmailLink objEmailInfo)
        {
            EmailMessages objEmail = EmailMessages.Instance;
            //StringBuilder sbToEmail = new StringBuilder();
            //string strMessageSubject = GetMessageSubject(objEmailInfo);
            //string strMessageBody = GetEmailBody(objEmailInfo);

            foreach (string strEmail in objEmailInfo.EmailTo)
            {
                bool val = objEmail.SendMessages(objEmailInfo.FromEmailAddress, strEmail, objEmailInfo.EmailSubject, objEmailInfo.EmailBody, EmailMessages.TextFormat.Html.ToString());
            }
        }
        /// <summary>
        /// Method to get the body part of email.
        /// </summary>
        /// <param name="objUserInfo">Filled EmailLink entity</param>
        /// <returns>HTML string of body part</returns>
        private string GetEmailBody(EmailLink objEmailInfo)
        {
            string strTypeName = objEmailInfo.TypeName;

            StringBuilder sbEmailbody = new StringBuilder();
            try
            {
                sbEmailbody.Append("<font style='font-size: 12px; font-family:Lucida Sans;'><p>" + objEmailInfo.FromUserName);
                if (objEmailInfo.TypeName == "GuestBook")
                    sbEmailbody.Append(" wants you to read a guestbook in the tribute.</p>");
                else
                    sbEmailbody.Append(" wants you to view the Tribute.</p>");

                sbEmailbody.Append("<p>To view the ");
                sbEmailbody.Append(strTypeName.ToLower());
                sbEmailbody.Append(", follow the link below:<br/>");

                //if (objEmailInfo.TypeName == "VideoGallery") //url for video gallery page
                //    sbEmailbody.Append("<a href='" + objEmailInfo.UrlToEmail + "?UserTributeId=1'>" + objEmailInfo.UrlToEmail + "</a>"); //TO DO: TributeId to be picked from session
                //else if (objEmailInfo.TypeName == "ManageVideo") //url for Manage Video page
                //    sbEmailbody.Append("<a href='" + objEmailInfo.UrlToEmail + "'>" + objEmailInfo.UrlToEmail + "</a>");
                //else if (objEmailInfo.TypeName == "GuestBook") //url for Guest Book page

                sbEmailbody.Append(objEmailInfo.UrlToEmail + "</p>");

                sbEmailbody.Append("<p>---<br/>");
                sbEmailbody.Append("Your Tribute Team</p></font>");

                //sbEmailbody.Append("Regards <br/>" + objEmailInfo.FromEmailAddress);
            }
            catch (Exception ex)
            {
                //throw ex.Message;
            }
            return sbEmailbody.ToString();
        }
    private void SetValueForEmailInSession(string typeName)
    {
        StateManager stateManager = StateManager.Instance;
        EmailLink objEmail = new EmailLink();
        objEmail.EmailBody = "<font style='font-size: 12px; font-family:Lucida Sans;'>";
        string PageName = "";
        string ApplicationPath = "<a href='" + URL + "'>" + URL + "</a>";
        string UrlToEmail = ApplicationPath;
        objEmail.FromEmailAddress = _emailID;

        if (typeName == "GuestBook")
        {
            PageName = "Guestbook";
        }
        else if (typeName == PortalEnums.TributeContentEnum.Story.ToString())
        {
            PageName = PortalEnums.TributeContentEnum.Story.ToString();
        }
        else if (typeName == PortalEnums.TributeContentEnum.Gift.ToString())
        {
            PageName = PortalEnums.TributeContentEnum.Gift.ToString();
        }
        else if (typeName == PortalEnums.TributeContentEnum.Event.ToString())
        {
            PageName = PortalEnums.TributeContentEnum.Event.ToString();
        }
        else if (typeName == PortalEnums.TributeContentEnum.EventFullView.ToString())
        {
            PageName = PortalEnums.TributeContentEnum.Event.ToString();
        }
        else if (typeName == "TributeNotes")
        {
            PageName = PortalEnums.TributeContentEnum.Notes.ToString();
        }
        else if (typeName == "NoteFullView")
        {
            PageName = PortalEnums.TributeContentEnum.Notes.ToString();
        }
        else if (typeName == "VideoGallery")
        {
            PageName = "Videos";
        }
        else if (typeName == "ManageVideo")
        {
            PageName = "Video";
        }
        else if (typeName == "PhotoGallery")
        {
            PageName = "Photos";
        }
        else if (typeName == "PhotoAlbum")
        {
            PageName = "Photo Album";
        }
        else if (typeName == "PhotoFullView")
        {
            PageName = "Photo";
        }
        else if (typeName == "ManageVideoTribute")
        {
            PageName = "VideoTribute";
        }

        if (typeName == "TributeNotes")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtReadEmailWThe_SM_Master") + " " + PageName + " " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "NoteFullView")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtReadEmail_SM_Master") + " Note " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "Event")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWTA_SM_Master") + " Events " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "EventFullView")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtViewEmailEvent_SM_Master") + " Event " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "Gift")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWTA_SM_Master") + " Gifts " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "GuestBook")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtReadEmail_SM_Master") + " Guestbook " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "Story")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtReadEmail_SM_Master") + " Story " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "VideoGallery")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWTA_SM_Master") + " a Video " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "PhotoGallery")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWTA_SM_Master") + " Photos " + ResourceText.GetString("txtOnYT_SM_Master");
        else if (typeName == "ManageVideoTribute")
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWTA_SM_Master") + " a Video Tribute " + ResourceText.GetString("txtOnYT_SM_Master");
        else
            objEmail.EmailSubject = txtUserName.Text + " " + ResourceText.GetString("txtViewEmail_SM_Master") + " " + PageName + " " + ResourceText.GetString("txtOnYT_SM_Master");

        objEmail.TypeName = typeName;

        StringBuilder sbEmailbody = new StringBuilder();

        if (typeName == "TributeNotes")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtReadEmailWThe_SM_Master") + " " + PageName + " in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "NoteFullView")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtReadEmail_SM_Master") + " Note in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "Event")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWThe_SM_Master") + " Events in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "EventFullView")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtViewEmailEvent_SM_Master") + " Event in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "Gift")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWThe_SM_Master") + " Gifts in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "GuestBook")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtReadEmailWThe_SM_Master") + " Guestbook in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "Story")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtReadEmail_SM_Master") + " Story in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "VideoGallery")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWTA_SM_Master") + " a Video in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "PhotoGallery")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWThe_SM_Master") + " Photos in the " + _tributeName + " " + _tributeType + " Tribute.");
        else if (typeName == "ManageVideoTribute")
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtViewEmailWTA_SM_Master") + " a Video Tribute in the " + _tributeName + " " + _tributeType + " Tribute.");
        else
            sbEmailbody.Append(txtUserName.Text + " " + ResourceText.GetString("txtViewEmail_SM_Master") + " " + PageName + " in the " + _tributeName + " " + _tributeType + " Tribute.");

        sbEmailbody.Append("<br/>");
        sbEmailbody.Append("<br/>");
        if (typeName == "Event")
            sbEmailbody.Append(ResourceText.GetString("txtToView_SM_Master") + " Events" + ResourceText.GetString("txtFollowLink_SM_Master"));
        else if (typeName == "Gift")
            sbEmailbody.Append(ResourceText.GetString("txtToView_SM_Master") + " Gifts" + ResourceText.GetString("txtFollowLink_SM_Master"));
        else if (typeName == "NoteFullView")
            sbEmailbody.Append(ResourceText.GetString("txtToView_SM_Master") + " Note" + ResourceText.GetString("txtFollowLink_SM_Master"));
        else if (typeName == "VideoGallery")
            sbEmailbody.Append(ResourceText.GetString("txtToView_SM_Master") + " Video" + ResourceText.GetString("txtFollowLink_SM_Master"));
        else if (typeName == "ManageVideoTribute")
            sbEmailbody.Append(ResourceText.GetString("txtToView_SM_Master") + " Video Tribute" + ResourceText.GetString("txtFollowLink_SM_Master"));
        else
            sbEmailbody.Append(ResourceText.GetString("txtToView_SM_Master") + " " + PageName + ResourceText.GetString("txtFollowLink_SM_Master"));

        sbEmailbody.Append("<br/>");
        sbEmailbody.Append(UrlToEmail);
        sbEmailbody.Append("<br/>");
        sbEmailbody.Append("<br/>");
        sbEmailbody.Append("---");
        sbEmailbody.Append("<br/>");
        sbEmailbody.Append(ResourceText.GetString("txtFrom_SM_Master"));

        objEmail.EmailBody = objEmail.EmailBody + sbEmailbody.ToString();
        stateManager.Add(PortalEnums.SessionValueEnum.ShareTributeEmail.ToString(), objEmail, StateManager.State.Session);
    }
    public void SendEmail(List<string> lstEmailAdd)
    {
        StateManager stateManager = StateManager.Instance;
        EmailLink objEmail = (EmailLink)stateManager.Get(PortalEnums.SessionValueEnum.ShareTributeEmail.ToString(), StateManager.State.Session);
        string URLToEmail = URL;
        EmailLink objEmailLink = new EmailLink();
        objEmailLink.FromEmailAddress = txtUserEmailAddress.Text;
        objEmailLink.FromUserName = txtUserName.Text;
        objEmailLink.EmailTo = lstEmailAdd;
        objEmailLink.UrlToEmail = objEmail.UrlToEmail;
        objEmailLink.TypeName = objEmail.TypeName;
        objEmailLink.EmailBody = objEmail.EmailBody;
        objEmailLink.EmailSubject = objEmail.EmailSubject;

        MessagingSystemController objMsg = new MessagingSystemController();
        objMsg.SendEmail(objEmailLink);
    }
    protected void lbtnEmailTribute_Click(object sender, EventArgs e)
    {
        StateManager stateManager = StateManager.Instance;
        EmailLink objEmail = new EmailLink();
        string EmailHref = string.Empty;
        if (Request.Cookies["topurl"] != null)
        {
            _TopUrl = Request.Cookies["topurl"].Value.ToString().Trim().ToLower();
        }
        if (Session["isInIframe"] != null)
        {
            isInIframe = bool.Parse(Session["isInIframe"].ToString());
            Session["isInIframe"] = null;
        }
        if (!(string.IsNullOrEmpty(_TopUrl)) && isInIframe)
        {
            EmailHref = _TopUrl + "?http://" + _tributeType.ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/" + _tributeUrl;
        }
        else
        {
            EmailHref = "http://" + _tributeType.ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/" + _tributeUrl;
        }
        string UrlToEmail = "<a href='" + EmailHref + "'>" + EmailHref + "</a>";

        if (_firstName == string.Empty)
        {
            objEmail.EmailSubject = _userName + " wants you to view a " + _tributeType + " Tribute on Your Tribute...";
            objEmail.EmailBody = "<font style='font-size: 12px; font-family:Lucida Sans;'><p>" + _userName + " wants you to view the " + _tributeName + " Tribute.</p> <p>To view the tribute, follow the link below: " + "<br/>" + UrlToEmail + "</p></font>";
        }
        else
        {
            objEmail.EmailSubject = _firstName + " " + _lastName + " wants you to view a " + _tributeType + " Tribute on Your Tribute...";
            objEmail.EmailBody = "<font style='font-size: 12px; font-family:Lucida Sans;'><p>" + _firstName + " " + _lastName + " wants you to view the " + _tributeName + " Tribute.</p> <p>To view the tribute, follow the link below: " + "<br/>" + UrlToEmail + "</p>";
        }
        objEmail.TypeName = _typeName;
        objEmail.FromEmailAddress = _emailID;

        stateManager.Add(PortalEnums.SessionValueEnum.ShareTributeEmail.ToString(), objEmail, StateManager.State.Session);
        // Added by Ashu on Oct 4, 2011 for rewrite URL 
        if (ConfigurationManager.AppSettings["ApplicationType"].ToString().ToLower() == "yourmoments")
            Response.Redirect("~/" + Session["TributeURL"] + "/shareMoments.aspx", false);
        else
            Response.Redirect("~/" + Session["TributeURL"] + "/sharetribute.aspx", false);

    }
 public void SendEmail(EmailLink objEmail)
 {
     FacadeManager.MessagingSystemManager.SendEmail(objEmail);
 }
    /// <summary>
    /// Method to set the url to be mailed to user.
    /// </summary>
    private void SetValueForEmailInSession()
    {
        StateManager stateManager = StateManager.Instance;

        //TO DO: to be removed
        //SessionValue _objSessionValue = new SessionValue(1, "Gaurav", "Puri", "Gaurav Puri", "*****@*****.**", 1, "Admin");
        //stateManager.Add("objSessionvalue", _objSessionValue, StateManager.State.Session);

        EmailLink objEmail = new EmailLink();
        objEmail.TypeName = stateManager.Get("TypeName", StateManager.State.ViewState).ToString();
        objEmail.UrlToEmail = Request.Url.ToString();
        stateManager.Add("objEmailLink", objEmail, StateManager.State.Session);
    }
    /// <summary>
    /// This function will get the values (User Id and Tribute Detail) from the session
    /// </summary>
    private void GetValuesFromSession()
    {
        try
        {
            Response.Cache.SetExpires(DateTime.Now);

            // Get values from session
            StateManager objStateManager = StateManager.Instance;

            // To get user id from session as user is logged in user
            objSessionValue = (SessionValue)objStateManager.Get(PortalEnums.SessionValueEnum.objSessionvalue.ToString(), StateManager.State.Session);
            if (objSessionValue != null)
            {
                _UserId = objSessionValue.UserId;
                _UserName = objSessionValue.UserName;
            }
            else
            {
                _IsAdmin = false;
            }

            // to get tribute detail from session
            objTribute = (Tributes)objStateManager.Get(PortalEnums.SessionValueEnum.TributeSession.ToString(), StateManager.State.Session);
            if (objTribute != null)
            {
                _TributeId = objTribute.TributeId;
                _TributeName = objTribute.TributeName;
                _TributeType = objTribute.TypeDescription;
                _TributeUrl = objTribute.TributeUrl;
            }

            // to get tribute detail from session
            objEmail = (EmailLink)objStateManager.Get(PortalEnums.SessionValueEnum.ShareTributeEmail.ToString(), StateManager.State.Session);
            if (objEmail != null)
            {
                _EmailBody = objEmail.EmailBody;
                _EmailSubject = objEmail.EmailSubject;

                if (objEmail.FromEmailAddress != null && objEmail.FromEmailAddress.Length != 0)
                    _EmailFrom = objEmail.FromEmailAddress;
                else
                {
                    _EmailSubject = "Someone" + objEmail.EmailSubject;
                    //_EmailBody = "Someone" + objEmail.EmailBody;
                    //{
                    //    if (_EmailBody.Contains("<p>"))
                    //        _EmailBody = _EmailBody.Remove(_EmailBody.IndexOf("<p>"), 3);
                    //}
                    _EmailFrom = "Your Tribute <" + WebConfig.ForgetPassAdmin + ">";
                }
                SetPageName(objEmail.TypeName);
            }

            // If user and Tribute id is blank then redirect to the login page
            if ((_TributeId == 0) || (objEmail == null))
            {
                Response.Redirect(Redirect.RedirectToPage(Redirect.PageList.Inner2LoginPage.ToString()), false);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }