Пример #1
0
        public static string GetUrlFromLinkID(string LinkID)
        {
            string LinkUrl = string.Empty;
            if (LinkID.Contains("!RPLINK"))
            {
                //string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                string[] startDelimiter = new string[] { "[!RPLINK:" };
                string[] endDelimiter = new string[] { "!]" };
                string[] splittedContent = LinkID.Split(startDelimiter, StringSplitOptions.None);

                for (int i = 1; i < splittedContent.Length; i++)
                {
                    string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                    //get linkDetails using linkID.
                    //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                    if (!string.IsNullOrEmpty(linkID))
                    {
                        LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                        if (objLinkDetail.ID != 0)
                        {
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            if (linkData != null)
                            {
                                LinkUrl = linkData.LinkURL;
                            }
                        }
                    }
                }
            }
            return LinkUrl;
        }
Пример #2
0
        public void Automationcampaigns_bindcontent()
        {
            try
            {
                ACpk = new AutomationMasterPrimaryKey(campaignID);
                AcampMaster = AutomationMaster.SelectOne(ACpk, ConnectionString);
                lblCampaignName.Text = AcampMaster.CampaignName;
                lblFromAddress.Text = AcampMaster.FromAddress;
                lblFromName.Text = AcampMaster.FromName;
                if (AcampMaster.Subject.StartsWith("http"))
                {
                    Byte[] PageHTMLBytes;
                    WebClient MyWebClient = new WebClient();
                    UTF8Encoding oUTF8 = new UTF8Encoding();

                    PageHTMLBytes = MyWebClient.DownloadData(AcampMaster.Subject);
                    string tempPageHTMLBytes = oUTF8.GetString(PageHTMLBytes).ToString();
                    lblSubject.Text = tempPageHTMLBytes;
                }
                else
                {
                    lblSubject.Text = AcampMaster.Subject;
                }
                string campaignContent = string.Empty;
                if (AcampMaster.HTMLContent.StartsWith("http"))
                {
                    Byte[] PageHTMLBytes;
                    WebClient MyWebClient = new WebClient();
                    UTF8Encoding oUTF8 = new UTF8Encoding();
                    PageHTMLBytes = MyWebClient.DownloadData(AcampMaster.HTMLContent);
                    string tempPageHTMLBytes = oUTF8.GetString(PageHTMLBytes).ToString();
                    campaignContent = tempPageHTMLBytes;
                }
                else
                {
                    campaignContent = AcampMaster.HTMLContent;
                }
                if (campaignContent.ToLower().Contains("listunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "<A href=\"" + System.Configuration.ConfigurationManager.AppSettings["UnSubscribeLinkPath"] + "\">List UnSubscribe</A>");
                }
                if (campaignContent.ToLower().Contains("globalunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "<A href=\"" + System.Configuration.ConfigurationManager.AppSettings["UnSubscribeLinkPath"] + "\">Global UnSubscribe</A>");
                }
                if (campaignContent.ToLower().Contains("forwardtofriend"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "<A href=\"" + System.Configuration.ConfigurationManager.AppSettings["ForwardToFriendLinkPath"] + "\">Forward To Friend</A>");
                }
                if (campaignContent.ToLower().Contains("mirrorweblink"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "<A href=\"" + System.Configuration.ConfigurationManager.AppSettings["ClickHearURL"] + "?ID=" + Convert.ToInt32(campaignID) + "&type=" + Request.QueryString["type"] + "&EditorType=" + "HTML" + "\">click here</A>");
                }
                //Add click link to the content.
                #region this logic will add click link to the content

                if (campaignContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);

                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);

                            if (linkData != null)
                            {
                                if (campaignContent.ToLower().Contains(linkID))
                                {
                                    campaignContent = campaignContent.Replace(linkID, linkData.LinkURL.ToString());
                                }
                            }
                        }
                    }
                }
                #endregion
                contentdiv.InnerHtml = campaignContent;
                ViewState["Content"] = campaignContent;
            }
            catch (Exception ex)
            {
                lbltitle.Text = "Invalid Campaign";
            }
        }
Пример #3
0
        public void creatives_bindContent()
        {
            try
            {
                pk = new TemplateMasterPrimaryKey(templateID);
                tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
                templateContent = tempMaster.HTMLContent;
                AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();

                if (templateContent.ToLower().Contains("listunsubscribe"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "javascript:onClick=alert('List UnSubscribe link will be activated after your email is sent.)'>");
                }
                if (templateContent.ToLower().Contains("globalunsubscribe"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "javascript:onClick=alert('Global UnSubscribe link will be activated after your email is sent.')");
                }
                if (templateContent.ToLower().Contains("forwardtofriend"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "javascript:onClick=alert('Forward link will be activated after your email is sent.')");
                }
                if (templateContent.ToLower().Contains("mirrorweblink"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "javascript:onClick=alert('Hosted version link will be activated after your email is sent.')");
                }

                if (templateContent.ToLower().Contains("amm"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:AMM!]", "javascript:onClick=alert('AMM version link Can not be activated in Preview Or Test mode.')");
                }
                if (templateContent.ToLower().Contains("amm2"))
                {
                    templateContent = templateContent.Replace("[!RPLINK:AMM2!]", "javascript:onClick=alert('AMM2 version link Can not be activated in Preview Or Test mode.')");
                }
                #region this logic will add click link to the content

                if (templateContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = templateContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            LinkURL = linkData.LinkURL;
                            if (linkData != null)
                            {
                                if (templateContent.ToLower().Contains(linkID))
                                {
                                    templateContent = templateContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                }
                            }
                        }
                    }
                }

                #endregion
                contentdiv.InnerHtml = templateContent;
                ViewState["Content"] = templateContent;
            }
            catch (Exception ex)
            {
                lbltitle.Text = "Invalid Creatives";
            }
        }
Пример #4
0
        public void campaigns_bindcontentwithoutId(string Htmlcontent)
        {
            try
            {
                AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();
                string campaignContent = Htmlcontent;
                chkShowCamStuff.Visible = false;

                #region handle standared links

                if (campaignContent.ToLower().Contains("listunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "javascript:onClick=alert('UnSubscribe links will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("globalunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "javascript:onClick=alert('Global UnSubscribe link will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("forwardtofriend"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "javascript:onClick=alert('Forward link will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("mirrorweblink"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "javascript:onClick=alert('Hosted version link will be activated after your email is sent.')");
                }

                #endregion

                //Add click link to the content.
                #region this logic will add click link to the content

                if (campaignContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            LinkURL = linkData.LinkURL;
                            if (linkData != null)
                            {
                                string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                                if (campaignContent.ToLower().Contains(linkID))
                                {
                                    campaignContent = campaignContent.Replace(replaceToken, LinkURL);
                                }
                            }
                        }
                    }
                }
                #endregion
                contentdiv.InnerHtml = campaignContent;
                ViewState["Content"] = campaignContent;
            }
            catch (Exception ex)
            {
                lbltitle.Text = "Invalid Campaign";
            }
        }
Пример #5
0
        public void campaigns_bindcontent(string Htmlcontent)
        {
            try
            {
                AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();
                Cpk = new CampaignMasterPrimaryKey(campaignID);
                campMaster = CampaignMaster.SelectOne(Cpk, ConnectionString);
                lblCampaignName.Text = campMaster.CampaignName;
                lblFromAddress.Text = campMaster.FromAddress;
                lblFromName.Text = campMaster.FromName;
                lblSubject.Text = campMaster.Subject;
                trackReads = campMaster.TrackReads.ToString();

                if (Request.QueryString["Ptype"] == "GridCampaign")
                {
                    campaignContent = campMaster.HTMLContent;
                }
                else
                {
                    campaignContent = Htmlcontent;
                }
                if (!campaignContent.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                {
                    campaignContent = campaignContent + "<br />If you no longer wish to receive these emails, simply click on the following link:<a href='[!RPLINK:GLOBALUNSUBSCRIBE!]'>Unsubscribe</a>";
                }

                chkShowCamStuff.Visible = true;

                #region handle standared links

                if (campaignContent.ToLower().Contains("listunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "javascript:onClick=alert('UnSubscribe links will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("globalunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "javascript:onClick=alert('Global UnSubscribe link will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("forwardtofriend"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "javascript:onClick=alert('Forward link will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("mirrorweblink"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "javascript:onClick=alert('Hosted version link will be activated after your email is sent.')");
                }
                if (campaignContent.ToLower().Contains("amm"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:AMM!]", "javascript:onClick=alert('AMM version link Can not be activated in Preview Or Test mode.')");
                }
                if (campaignContent.ToLower().Contains("amm2"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:AMM2!]", "javascript:onClick=alert('AMM2 version link Can not be activated in Preview Or Test mode.')");
                }
                #endregion

                //Add click link to the content.
                #region this logic will add click link to the content

                if (campaignContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            LinkURL = linkData.LinkURL;
                            if (linkData != null)
                            {
                                string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                                if (campaignContent.ToLower().Contains(linkID))
                                {
                                    campaignContent = campaignContent.Replace(replaceToken, LinkURL);
                                }
                            }
                        }
                    }
                }
                #endregion
                contentdiv.InnerHtml = campaignContent;
                ViewState["Content"] = campaignContent;
            }
            catch (Exception ex)
            {
                lbltitle.Text = "Invalid Campaign";
            }
        }
        public void campaigns_bindcontent(string Textcontent)
        {
            try
            {
                AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();
                if (Request.QueryString["Ptype"] == "GridCampaign")
                {
                    Cpk = new CampaignMasterPrimaryKey(campaignID);
                    campMaster = CampaignMaster.SelectOne(Cpk, ConnectionString);
                    textContent = campMaster.TextContent;
                }
                else
                {
                    textContent = Textcontent;
                }
                if (!textContent.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                {
                    textContent = textContent + "<br />If you no longer wish to receive these emails, simply click on the following link:<a href='[!RPLINK:GLOBALUNSUBSCRIBE!]'>Unsubscribe</a>";
                }
                if (textContent.ToLower().Contains("listunsubscribe"))
                {
                    textContent = textContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "javascript:onClick=alert('UnSubscribe links will be activated after your email is sent.')");
                }
                if (textContent.ToLower().Contains("globalunsubscribe"))
                {
                    textContent = textContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "javascript:onClick=alert('Global UnSubscribe link will be activated after your email is sent.')");
                }
                if (textContent.ToLower().Contains("forwardtofriend"))
                {
                    textContent = textContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "javascript:onClick=alert('Forward link will be activated after your email is sent.')");
                }
                if (textContent.ToLower().Contains("mirrorweblink"))
                {
                    textContent = textContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "javascript:onClick=alert('Hosted version link will be activated after your email is sent.')");
                }

                #region this logic will add click link to the content

                if (textContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = textContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            LinkURL = linkData.LinkURL;
                            if (linkData != null)
                            {
                                string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                if (textContent.ToLower().Contains(linkID))
                                {
                                    textContent = textContent.Replace(replaceToken, LinkURL);
                                }
                            }
                        }
                    }
                }
                #endregion
                contentdiv.InnerHtml = textContent;
                ViewState["Content"] = textContent;
                Session["Textcontent"] = null;
            }
            catch (Exception ex)
            {
                //throw;
            }
        }
Пример #7
0
        public void mailContentSeed(DataRow dr, string campaignContent, string pToAddress, string pFromAddress, string pReplyAddress, string pSubject, string pEmailErrorMessage, bool pIsMultipleRecipients, string ConnectionString)
        {
            #region this logic will replaces personalised fields.
            try
            {
                if (campaignContent.Contains("[!FirstName!]"))
                {
                    campaignContent = campaignContent.Replace("[!FirstName!]", dr["FirstName"].ToString());
                }
                if (campaignContent.Contains("[!LastName!]"))
                {
                    campaignContent = campaignContent.Replace("[!LastName!]", dr["Lastname"].ToString());
                }

                if (campaignContent.Contains("[!EmailAddress!]"))
                {
                    campaignContent = campaignContent.Replace("[!EmailAddress!]", dr["EmailAddress"].ToString());
                }


                DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(ConnectionString);
                for (int i = 0; i < customFieldDt.Rows.Count; i++)
                {
                    string startChars = "[!";
                    string endChars = "!]";
                    string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                    string customColName;
                    if (campaignContent.Contains(strCustomCtrl))
                    {
                        //alCustonFields.Add(customFieldDt.Rows[i]["ContactFieldName"].ToString());
                        customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                        campaignContent = campaignContent.Replace(strCustomCtrl, dr[customColName].ToString());
                    }
                }
                //Subject
                if (pSubject.Contains("[!FirstName!]"))
                {
                    pSubject = pSubject.Replace("[!FirstName!]", dr["FirstName"].ToString());
                }
                if (pSubject.Contains("[!LastName!]"))
                {
                    pSubject = pSubject.Replace("[!LastName!]", dr["Lastname"].ToString());
                }

                if (pSubject.Contains("[!EmailAddress!]"))
                {
                    pSubject = pSubject.Replace("[!EmailAddress!]", dr["EmailAddress"].ToString());
                }
                for (int i = 0; i < customFieldDt.Rows.Count; i++)
                {
                    string startChars = "[!";
                    string endChars = "!]";
                    string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                    string customColName;
                    if (pSubject.Contains(strCustomCtrl))
                    {
                        customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                        pSubject = pSubject.Replace(strCustomCtrl, dr[customColName].ToString());
                    }
                }

                string AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();
                if (campaignContent.ToLower().Contains("listunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", AleartMsgPath + "?TypeOfLink=UnSubscribe");
                }
                if (campaignContent.ToLower().Contains("globalunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", AleartMsgPath + "?TypeOfLink=UnSubscribe");
                }
                if (campaignContent.ToLower().Contains("forwardtofriend"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", AleartMsgPath + "?TypeOfLink=Forward");
                }
                if (campaignContent.ToLower().Contains("mirrorweblink"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", AleartMsgPath + "?TypeOfLink=Mirror");
                }

                if (campaignContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                            if (objLinkDetail.ID != 0)
                            {
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData != null)
                                {
                                    string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                                    campaignContent = campaignContent.Replace(replaceToken, linkData.LinkURL);
                                }
                            }
                        }
                    }
                }
                string pBody = campaignContent;

                bool pResult = sendEMail(pFromAddress, pToAddress, pReplyAddress, pSubject, pIsMultipleRecipients, pBody, out pEmailErrorMessage);
                if (!pResult)
                {
                    pEmailErrorMessage = Server.HtmlEncode(pEmailErrorMessage);
                }
            }
            catch (Exception ex)
            {
            }
            #endregion
        }
Пример #8
0
        public void showCampaignSummary(string campaignID)
        {
            try
            {

                //get summary details of campaign
                CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(campaignID));
                CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);

                CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(campaignID), ConnectionString);


                String htmlContent = objCampaignMaster.HTMLContent;

                #region this logic will add click link to the content

                if (htmlContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = htmlContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        //LinkDetails objLinkDetail = LinkDetail.SelectByField("ID", linkID);
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData != null)
                                {
                                    if (linkData.LinkURL.ToLower().Contains("http://"))
                                        linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                    LinkURL = linkData.LinkURL;
                                    if (!hashtable.Contains(LinkURL))
                                        hashtable.Add(linkData.LinkURL, linkData.clickCount);
                                    if (htmlContent.ToLower().Contains(linkID))
                                    {
                                        htmlContent = htmlContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }

                    }

                }

                #endregion

                string textContent = objCampaignMaster.TextContent;

                #region this logic will add click link to the content

                if (textContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = textContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        //LinkDetails objLinkDetail = LinkDetail.SelectByField("ID", linkID);
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData != null)
                                {
                                    if (linkData.LinkURL.ToLower().Contains("http://"))
                                        linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                    LinkURL = linkData.LinkURL;
                                    if (!hashtable.Contains(LinkURL))
                                        hashtable.Add(linkData.LinkURL, linkData.clickCount);
                                    if (textContent.ToLower().Contains(linkID))
                                    {
                                        textContent = textContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }

                    }

                }

                #endregion
                if (textContent != string.Empty)
                {
                    textContent = textContent.Replace("&quot;", "\"");
                    textContent = textContent.Replace("&lt;", "<");
                    textContent = textContent.Replace("&gt;", ">");
                }
                if (htmlContent != string.Empty)
                    HTMLlist = LinkFinder(htmlContent);
                if (textContent != string.Empty)
                    Textlist = LinkFinder(textContent);

                if (Textlist.Count > 0)
                    HTMLlist = HTMLlist.Concat(Textlist).ToList();

                string[] finalArray = new string[HTMLlist.Count];

                for (int i = 0; i < HTMLlist.Count; i++)
                {
                    finalArray[i] = HTMLlist[i].Href;

                }
                finalArray = finalArray.Distinct().ToArray();


                if (objCampaignMaster.CampaignJobs[0].Status == 4)    //if (objCampaignMaster.CampaignJobs[0].Status == 1)
                {
                    string SelectCondition = objCampaignMaster.SelectCondition;
                    string[] ListIds = SelectCondition.Split(',');
                    //string selectedList=null;
                    StringBuilder selectedList = new StringBuilder();
                    StringBuilder selectedListExport = new StringBuilder();
                    foreach (var Id in ListIds)
                    {

                        ListMasters List = ListMaster.SelectByField("ListMasterId", Id, ConnectionString);
                        if (List.Count > 0)
                        {
                            selectedList.Append(List[0].ListName.ToString() + ", ");
                            selectedListExport.Append(List[0].ListName.ToString() + "; ");
                        }
                        else
                        {
                            lblMainMsg.Style.Add("color", "red");
                            lblMainMsg.Text = "The List has been moved or removed";

                        }

                    }
                    if (selectedList.Length > 0)
                    {
                        selectedList.Remove(selectedList.Length - 2, 1);
                    }
                    else
                    {
                        //lblMainMsg.Style.Add("color", "red");
                        //lblMainMsg.Text = "The List has been moved or removed";
                        selectedList.Append("The List has been moved or removed");
                    }

                    if (selectedListExport.Length > 0)
                    {
                        selectedListExport.Remove(selectedListExport.Length - 2, 1);
                    }
                    else
                    {
                        //lblMainMsg.Style.Add("color", "red");
                        //lblMainMsg.Text = "The List has been moved or removed";
                        selectedListExport.Append("The List has been moved or removed");
                    }

                    string campaignName = objCampaignMaster.CampaignName;
                    string subject = objCampaignMaster.Subject;
                    int openCount = 0, sentCount = 0, clickCount = 0, optoutCount = 0, bounceCount = 0;
                    if (objCampaignjob[0].DeliveredCount != 0 || objCampaignjob[0].BounceCount != 0)
                    {
                        //get counts
                        openCount = Convert.ToInt32(objCampaignjob[0].OpenCount);
                        sentCount = Convert.ToInt32(objCampaignjob[0].DeliveredCount);
                        clickCount = Convert.ToInt32(objCampaignjob[0].ClickCount);
                        optoutCount = Convert.ToInt32(objCampaignjob[0].OptoutCount);
                        bounceCount = Convert.ToInt32(objCampaignjob[0].BounceCount);
                    }
                    int totalrecipients = Convert.ToInt32(objCampaignjob[0].TotalRecipients);
                    decimal averageOpenCount = 0, averageClickCount = 0, averageOptOutCount = 0, averageSentCount = 0, averageBounceCount = 0;
                    //calculate averages
                    if (sentCount != 0)
                        averageOpenCount = Decimal.Round(Convert.ToDecimal(openCount) / Convert.ToDecimal(sentCount) * 100, 1);
                    else
                        averageOpenCount = 0;
                    //else
                    //     averageOpenCount =0;
                    if (openCount != 0)
                        averageClickCount = Decimal.Round(Convert.ToDecimal(clickCount) / Convert.ToDecimal(openCount) * 100, 1);
                    else
                        averageClickCount = 0;
                    //else
                    //     averageClickCount =0;
                    if (sentCount != 0)
                        averageOptOutCount = Decimal.Round(Convert.ToDecimal(optoutCount) / Convert.ToDecimal(sentCount) * 100, 1);
                    else
                        averageOptOutCount = 0;
                    //else
                    //     averageOptOutCount=0;
                    if (totalrecipients != 0)
                        averageSentCount = Decimal.Round(Convert.ToDecimal(sentCount) / Convert.ToDecimal(totalrecipients) * 100, 1);
                    else
                        averageSentCount = 0;
                    //else

                    if (bounceCount != 0)
                        averageBounceCount = Decimal.Round(Convert.ToDecimal(bounceCount) / Convert.ToDecimal(totalrecipients) * 100, 1);
                    else
                        averageBounceCount = 0;
                    //build html string for campaign summary.
                    StringBuilder objStringBuilder = new StringBuilder();
                    objStringBuilder.Append("<table width=\"100%\" border=\"0px\" cellspacing=\"0px\">");

                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");
                    objStringBuilder.Append("<tr><td width=\"25%\"><b>Campaign Details Criteria</b></td><td width=\"25%\"></td><td width=\"25%\"><b>Recipient Criteria</b></td><td></td></tr>");
                    objStringBuilder.Append("<tr><td width=\"25%\">Campaign Name</td><td width=\"25%\">" + campaignName + "</td> <td width=\"25%\">List(s) Selected</td><td width=\"25%\">" + selectedList + "</td></tr>");
                    objStringBuilder.Append("<tr><td >Results as Of</td><td>" + DateTime.Now + "</td><td >Recipients Found</td><td>" + (totalrecipients) + "</td></tr>");
                    objStringBuilder.Append("<tr><td >Send Start Date</td><td>" + objCampaignjob[0].StartTime.ToString() + "</td><td>Subject</td><td>" + subject + "</td></tr>");
                    objStringBuilder.Append("<tr><td >Send Completion Date</td><td>" + objCampaignjob[0].CompletionTime.ToString() + "</td><td></td><td></td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("</td></tr>");

                    objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");

                    //objStringBuilder.Append("<tr><td>");
                    //objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");
                    //objStringBuilder.Append("<tr><td colspan=3><b>Recipient Criteria</b></td></tr>");
                    //objStringBuilder.Append("<tr><td width=\"25%\">List(s) Selected</td><td>" + selectedList + "</td><td></td></tr>");
                    //objStringBuilder.Append("<tr><td >Recipients Found</td><td>" + (totalrecipients) + "</td><td></td></tr>");
                    //objStringBuilder.Append("</table>");
                    //objStringBuilder.Append("</td></tr>");

                    //objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");

                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");
                    objStringBuilder.Append("<tr><td width=\"25%\"><b>Send Details</b></td><td width=\"25%\"><b>Total</b></td><td><b>Average</b></td><td></td></tr>");
                    objStringBuilder.Append("<tr><td >Successful Sends</td><td width=\"25%\">" + sentCount + "</td><td>" + averageSentCount + "%</td></tr>");
                    objStringBuilder.Append("<tr><td >Bounces</td><td width=\"25%\">" + bounceCount + "</td><td>" + averageBounceCount + "%</td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("</td></tr>");

                    objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");

                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");
                    objStringBuilder.Append("<tr><td><b>Subscriber Interaction</b></td><td width=\"25%\"><b>Unique total</b></td><td><b>Average</b></td>");
                    objStringBuilder.Append("<tr><td width=\"25%\">Open</td><td width=\"25%\">" + openCount + "</td><td>" + averageOpenCount + "%</td></tr>");
                    objStringBuilder.Append("<tr><td >Click</td><td width=\"25%\">" + clickCount + "</td><td>" + averageClickCount + "%</td></tr>");
                    objStringBuilder.Append("<tr><td >OptOut</td><td width=\"25%\">" + optoutCount + "</td><td>" + averageOptOutCount + "%</td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("</td></tr>");

                    objStringBuilder.Append("<tr><td colspan=3><hr></td></tr>");

                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<table width=\"100%\">");
                    objStringBuilder.Append("<tr><td>");
                    objStringBuilder.Append("<tr><td width=\"40%\"><b>Custom URL Links</b></td><td style=\"padding-left:110px\" width=\"25%\"><b>Total Clicks</b></td><td ><b>Unique Clicks</b></td><td></td></tr>");
                    objStringBuilder.Append("</td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("<tr><td><div style=\"overflow:scroll;height:200px\">");
                    objStringBuilder.Append("<table width=\"100%\" class=\"roundcornerdiv\" border=\"0px\" cellspacing=\"0px\">");

                    if (finalArray.Length > 0)
                    {
                        for (int i = 0; i < finalArray.Length; i++)
                            //objStringBuilder.Append("<tr><td width=\"40%\">" + finalArray[i].ToString() + "</td><td style=\"padding-left:140px\" width=\"25%\">0</td><td style=\"padding-left:30px\">0</td><td></td></tr>");
                            if (hashtable.ContainsKey(finalArray[i].ToString()))
                            {
                                if (hashtable[finalArray[i].ToString()] != null)
                                    objStringBuilder.Append("<tr><td width=\"40%\">" + finalArray[i].ToString() + "</td><td style=\"padding-left:140px\" width=\"25%\">" + hashtable[finalArray[i].ToString()] + "</td><td style=\"padding-left:30px\">0</td><td></td></tr>");
                                else
                                    objStringBuilder.Append("<tr><td width=\"40%\">" + finalArray[i].ToString() + "</td><td style=\"padding-left:140px\" width=\"25%\">0</td><td style=\"padding-left:30px\">0</td><td></td></tr>");
                            }
                            else
                                objStringBuilder.Append("<tr><td width=\"40%\">" + finalArray[i].ToString() + "</td><td style=\"padding-left:140px\" width=\"25%\">0</td><td style=\"padding-left:30px\">0</td><td></td></tr>");
                    }
                    else
                        objStringBuilder.Append("<tr><td width=\"25%\" colspan=4> No links exist</td><td width=\"25%\"></td><td ></td><td></td></tr>");
                    objStringBuilder.Append("</table>");
                    objStringBuilder.Append("</div></td></tr>");
                    objStringBuilder.Append("</td></tr>");
                    objStringBuilder.Append("</table>");

                    //bind html string to the the td.

                    tdCampaignSummary.InnerHtml = objStringBuilder.ToString();

                    DataTable dtExportSummary = new DataTable();

                    DataColumn s1 = new DataColumn("Details");
                    DataColumn s2 = new DataColumn("Values");
                    DataColumn s3 = new DataColumn("AvgValues");

                    dtExportSummary.Columns.Add(s1);
                    dtExportSummary.Columns.Add(s2);
                    dtExportSummary.Columns.Add(s3);

                    DataRow row1 = dtExportSummary.NewRow();
                    row1[s1] = "campaignName";
                    row1[s2] = campaignName;
                    row1[s3] = "";
                    dtExportSummary.Rows.Add(row1);

                    DataRow row2 = dtExportSummary.NewRow();
                    row2[s1] = "Result as of";
                    row2[s2] = DateTime.Now;
                    row2[s3] = "";
                    dtExportSummary.Rows.Add(row2);

                    DataRow row3 = dtExportSummary.NewRow();
                    row3[s1] = "Send Start Date";
                    row3[s2] = objCampaignjob[0].StartTime.ToString();
                    row3[s3] = "";
                    dtExportSummary.Rows.Add(row3);

                    DataRow row4 = dtExportSummary.NewRow();
                    row4[s1] = "Send Completion Date";
                    row4[s2] = objCampaignjob[0].CompletionTime.ToString();
                    row4[s3] = "";
                    dtExportSummary.Rows.Add(row4);

                    DataRow row5 = dtExportSummary.NewRow();
                    row5[s1] = "List(s) Selected";
                    row5[s2] = selectedListExport;
                    row5[s3] = "";
                    dtExportSummary.Rows.Add(row5);

                    DataRow row6 = dtExportSummary.NewRow();
                    row6[s1] = "Recipients Found";
                    row6[s2] = totalrecipients;
                    row6[s3] = "";
                    dtExportSummary.Rows.Add(row6);

                    DataRow row7 = dtExportSummary.NewRow();
                    row7[s1] = "Successful Sends";
                    row7[s2] = sentCount;
                    row7[s3] = averageSentCount + "%";
                    dtExportSummary.Rows.Add(row7);

                    DataRow row8 = dtExportSummary.NewRow();
                    row8[s1] = "Bounces";
                    row8[s2] = bounceCount;
                    row8[s3] = averageBounceCount + "%";
                    dtExportSummary.Rows.Add(row8);

                    DataRow row9 = dtExportSummary.NewRow();
                    row9[s1] = "Open";
                    row9[s2] = openCount;
                    row9[s3] = averageOpenCount + "%";
                    dtExportSummary.Rows.Add(row9);

                    DataRow row10 = dtExportSummary.NewRow();
                    row10[s1] = "Click";
                    row10[s2] = clickCount;
                    row10[s3] = averageClickCount + "%";
                    dtExportSummary.Rows.Add(row10);

                    DataRow row11 = dtExportSummary.NewRow();
                    row11[s1] = "Opt Out";
                    row11[s2] = optoutCount;
                    row11[s3] = averageOptOutCount + "%";
                    dtExportSummary.Rows.Add(row11);

                    DataRow row12 = dtExportSummary.NewRow();
                    row11[s1] = "URL's";
                    row11[s2] = "ClickCount";
                    row11[s3] = "Unique Click Count";
                    dtExportSummary.Rows.Add(row12);

                    hashtablekeys = new ArrayList(hashtable.Keys);
                    hashtablevalues = new ArrayList(hashtable.Values);

                    for (int i = 0; i < hashtable.Count; i++)
                    {
                        DataRow row = dtExportSummary.NewRow();
                        row[s1] = hashtablekeys[i].ToString(); //hashtable.Keys.ToString();
                        if (hashtablevalues[i] != null)
                            row[s2] = hashtablevalues[i];//hashtable.Values.ToString();
                        else
                            row[s2] = 0;
                        row[s3] = 0;
                        dtExportSummary.Rows.Add(row);
                    }

                    ViewState["TempdtExportSummary"] = dtExportSummary;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #9
0
        public void mailContent(string campaignContent, string pToAddress, string pFromAddress, string pReplyAddress, string pSubject, string pEmailErrorMessage, bool pIsMultipleRecipients)
        {
            #region this logic will replaces personalised fields.
            try
            {
                if (txtSearch.Text != string.Empty)
                {
                    StringBuilder wherecondition = new StringBuilder();
                    if (txtSearch.Text.Trim().ToString() != string.Empty)
                        wherecondition.Append("EmailAddress ='" + txtSearch.Text + "'");
                    else
                        wherecondition.Append("1=1");
                    dtContacts = ContactMaster.SelectBySearchRecipients(wherecondition.ToString(), ConnectionString);
                    if (dtContacts.Rows.Count != 0)
                    {
                        PersonalizeFirstname = dtContacts.Rows[0]["FirstName"].ToString();
                        PersonalizeLastname = dtContacts.Rows[0]["LastName"].ToString();
                        PersonalizeEmail = dtContacts.Rows[0]["EmailAddress"].ToString();
                        if (campaignContent.Contains("[!FirstName!]"))
                        {
                            campaignContent = campaignContent.Replace("[!FirstName!]", PersonalizeFirstname);
                        }
                        if (campaignContent.Contains("[!LastName!]"))
                        {
                            campaignContent = campaignContent.Replace("[!LastName!]", PersonalizeLastname);
                        }

                        if (campaignContent.Contains("[!EmailAddress!]"))
                        {
                            campaignContent = campaignContent.Replace("[!EmailAddress!]", PersonalizeEmail);
                        }
                        DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(ConnectionString);
                        DataRow[] result = customFieldDt.Select("PersonalizedField=True");
                        foreach (DataRow dr in result)
                        {
                            string startChars = "[!";
                            string endChars = "!]";
                            string strCustomCtrl = startChars + dr["FieldName"].ToString() + endChars;
                            string customColName;
                            if (campaignContent.Contains(strCustomCtrl))
                            {
                                customColName = dr["ContactFieldName"].ToString();
                                DataTable contMasters = ContactMaster.SelectTopContact(ConnectionString);

                                foreach (DataRow drCus in contMasters.Rows)
                                {
                                    campaignContent = campaignContent.Replace(strCustomCtrl, drCus[customColName].ToString());
                                }
                            }
                        }
                        //Subject
                        if (pSubject.Contains("[!FirstName!]"))
                        {
                            pSubject = pSubject.Replace("[!FirstName!]", PersonalizeFirstname);
                        }
                        if (pSubject.Contains("[!LastName!]"))
                        {
                            pSubject = pSubject.Replace("[!LastName!]", PersonalizeLastname);
                        }

                        if (pSubject.Contains("[!EmailAddress!]"))
                        {
                            pSubject = pSubject.Replace("[!EmailAddress!]", PersonalizeEmail);
                        }
                        DataTable customFieldDt1 = ManageFieldsBase.SelectCustomFields(ConnectionString);
                        DataRow[] result1 = customFieldDt1.Select("PersonalizedField=True");
                        foreach (DataRow dr in result1)
                        {
                            string startChars = "[!";
                            string endChars = "!]";
                            string strCustomCtrl = startChars + dr["FieldName"].ToString() + endChars;
                            string customColName;
                            if (campaignContent.Contains(strCustomCtrl))
                            {
                                customColName = dr["ContactFieldName"].ToString();
                                DataTable contMasters = ContactMaster.SelectTopContact(ConnectionString);

                                foreach (DataRow drCus in contMasters.Rows)
                                {
                                    pSubject = pSubject.Replace(strCustomCtrl, drCus[customColName].ToString());
                                }
                            }
                        }
                    }
                }
                string AleartMsgPath = ConfigurationManager.AppSettings["AleartMsg"].ToString();
                if (campaignContent.ToLower().Contains("listunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", AleartMsgPath + "?TypeOfLink=UnSubscribe");
                }
                if (campaignContent.ToLower().Contains("globalunsubscribe"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", AleartMsgPath + "?TypeOfLink=UnSubscribe");
                }
                if (campaignContent.ToLower().Contains("forwardtofriend"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", AleartMsgPath + "?TypeOfLink=Forward");
                }
                if (campaignContent.ToLower().Contains("mirrorweblink"))
                {
                    campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", AleartMsgPath + "?TypeOfLink=Mirror");
                }

                if (campaignContent.Contains("!RPLINK"))
                {
                    //string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);

                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                            if (objLinkDetail.ID != 0)
                            {
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData != null)
                                {
                                    string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                                    campaignContent = campaignContent.Replace(replaceToken, linkData.LinkURL);
                                }
                            }
                        }
                    }
                }
                string pBody = campaignContent;
                bool pResult = sendEmail(pFromAddress, pToAddress, pReplyAddress, pSubject, pIsMultipleRecipients, pBody, out pEmailErrorMessage);
                if (!pResult)
                {
                    pEmailErrorMessage = Server.HtmlEncode(pEmailErrorMessage);
                }
            }
            catch (Exception ex)
            {
            }
            #endregion
        }
Пример #10
0
        public void CustomTrackUrls()
        {
            if (hiddenCampaignID.Value == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please save the Mailing to avail this option.')", true);
            }
            else
            {
                bindTemplates();
                CustomLabel objCustomLabel1 = new CustomLabel(ConnectionString);
                Int64 CampaignId = Convert.ToInt32(hiddenCampaignID.Value);
                Int64 TemplateId = (ddlTemplate.SelectedItem.Value != defaultListItem) ? Convert.ToInt32(ddlTemplate.SelectedItem.Value) : 0;
                DataTable CusLabel = objCustomLabel1.getCustomLabel(TemplateId, CampaignId);
                string customLabelingDivContent = "<table widht=\"670px\"><tbody><th widht=\"200px\" Align=\"left\"><B>Label</B></th><th widht=\"470px\" Align=\"left\"><B>URL</B></th>";
                htmlContent = RadEditor1.Content;
                #region this logic will add click link to the content

                if (htmlContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = htmlContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData.LinkURL.ToLower().Contains("http://"))
                                    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (linkData != null)
                                {
                                    if (htmlContent.ToLower().Contains(linkID))
                                    {
                                        htmlContent = htmlContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }

                    }

                }

                #endregion

                string textContent = textRadEditor.Content;

                #region this logic will add click link to the content

                if (textContent.Contains("!RPLINK"))
                {
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = textContent.Split(startDelimiter, StringSplitOptions.None);
                    string LinkURL = string.Empty;
                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        if (!string.IsNullOrEmpty(linkID))
                        {
                            if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                if (linkData.LinkURL.ToLower().Contains("http://"))
                                    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (linkData != null)
                                {
                                    if (textContent.ToLower().Contains(linkID))
                                    {
                                        textContent = textContent.Replace(startDelimiter[0] + linkID + endDelimiter[0], LinkURL.ToString());
                                    }

                                }
                            }
                        }
                    }
                }
                #endregion

                if (textContent != string.Empty)
                {
                    textContent = textContent.Replace("&quot;", "\"");
                    textContent = textContent.Replace("&lt;", "<");
                    textContent = textContent.Replace("&gt;", ">");
                }
                if (htmlContent != string.Empty)
                    HTMLlist = LinkFinder(htmlContent);
                if (textContent != string.Empty)
                    Textlist = LinkFinder(textContent);

                if (Textlist.Count > 0)
                    HTMLlist = HTMLlist.Concat(Textlist).ToList();

                List<string> URLlist = new List<string>();
                for (int i = 0; i < HTMLlist.Count; i++)
                {
                    URLlist.Add(HTMLlist[i].Href);
                }
                URLlist = URLlist.Distinct().ToList();
                if (CusLabel.Rows.Count != URLlist.Distinct().ToList().Count && CusLabel.Rows.Count > 0)
                {

                    for (int i = 0; i < CusLabel.Rows.Count; i++)
                    {
                        for (int j = 0; j < URLlist.Count; j++)
                        {
                            if (URLlist[j] == CusLabel.Rows[i]["LinkURL"].ToString())
                                URLlist.RemoveAt(j);
                        }
                    }
                    if (URLlist.Count > 0)
                    {
                        for (int i = 0; i < URLlist.Count; i++)
                        {
                            string txtBoxId = "txt" + i;
                            string divId = "div" + i;
                            customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + URLlist[i] + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + URLlist[i] + "</div></td></tr>";
                        }
                    }
                }
                if (CusLabel.Rows.Count != 0)
                {
                    for (int loopcount = 0; loopcount < CusLabel.Rows.Count; loopcount++)
                    {
                        string txtBoxId = "txt" + loopcount;
                        string divId = "div" + loopcount;
                        string str = string.Empty;
                        string url = string.Empty;

                        str = CusLabel.Rows[loopcount]["CustomLabel"].ToString();
                        url = CusLabel.Rows[loopcount]["LinkURL"].ToString();
                        customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + str + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + url + "</div></td></tr>";
                    }
                    customLabelingDivContent += "</tbody></table>";
                    customLabeling.InnerHtml = customLabelingDivContent;
                    customLabeling.Visible = true;
                }
                else if (URLlist.Count > 0)
                {
                    for (int i = 0; i < URLlist.Count; i++)
                    {
                        string txtBoxId = "txt" + i;
                        string divId = "div" + i;

                        customLabelingDivContent += "<tr widht=\"670px\"><td widht=\"200px\"><input type=\"text\" id='" + txtBoxId + "'runat=\"server\" value='" + URLlist[i] + "'></td><td><div id='" + divId + "'style=\"width:470px; word-wrap: break-word\">" + URLlist[i] + "</div></td></tr>";

                    }
                    customLabelingDivContent += "</tbody></table>";
                    customLabeling.InnerHtml = customLabelingDivContent;
                    customLabeling.Visible = true;
                }
                else
                { customLabelingDivContent += "<tr><td> No Links Found</td></tr>"; }


            }
        }
Пример #11
0
        private void showCampaignSummary(string mailingId)
        {
            try
            {
                DataTable dtExportSummary = new DataTable();
                if (mailingId != string.Empty)
                {
                    CampaignMasterPrimaryKey objCampaignMasterPrimaryKey = new CampaignMasterPrimaryKey(Convert.ToInt64(mailingId));
                    CampaignMaster objCampaignMaster = CampaignMaster.SelectOneWithCampaignJobUsingCampaignMasterID(objCampaignMasterPrimaryKey, ConnectionString);

                    CampaignJobs objCampaignjob = CampaignJob.SelectByField("CampaignMasterID", Convert.ToInt64(mailingId), ConnectionString);
                    String htmlContent = objCampaignMaster.HTMLContent;
                    //lblCampaignTitle.Text = objCampaignMaster.CampaignName.ToString();

                    #region this logic will add click link to the content

                    if (htmlContent.Contains("!RPLINK"))
                    {
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = htmlContent.Split(startDelimiter, StringSplitOptions.None);
                        string LinkURL = string.Empty;
                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail = LinkDetail.SelectByField("ID", linkID);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                                {
                                    if (LinkIds.Count == 0)
                                        LinkIds.Add(linkID);
                                    else
                                    {
                                        if (LinkIds.Contains(linkID) == false)
                                            LinkIds.Add(linkID);
                                    }
                                }
                            }

                        }
                        for (int i = 0; i < LinkIds.Count; i++)
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(LinkIds[i].ToString()));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);

                            LinkDetailBase.RecipientsLinkTotalAndUniqueCounts(ConnectionString, Convert.ToInt32(mailingId), Convert.ToInt32(LinkIds[i].ToString()), out totalClickCount, out UniqueClickCount);

                            if (linkData != null)
                            {
                                if (linkData.LinkURL.ToLower().Contains("http://"))
                                    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (!linkUrlName.Contains(LinkURL))
                                    linkUrlName.Add(linkData.LinkURL);
                                totalCountValues.Add(totalClickCount);
                                uniqueCountValues.Add(UniqueClickCount);
                                if (htmlContent.ToLower().Contains(LinkIds[i].ToString()))
                                {
                                    htmlContent = htmlContent.Replace(startDelimiter[0] + LinkIds[i].ToString() + endDelimiter[0], LinkURL.ToString());
                                }

                            }
                        }
                    }

                    #endregion

                    string textContent = objCampaignMaster.TextContent;

                    #region this logic will add click link to the content

                    if (textContent.Contains("!RPLINK"))
                    {
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = textContent.Split(startDelimiter, StringSplitOptions.None);
                        string LinkURL = string.Empty;
                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail = LinkDetail.SelectByField("ID", linkID);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                if ((linkID != "MIRRORWEBLINK") && (linkID != "LISTUNSUBSCRIBE") && (linkID != "FORWARDTOFRIEND") && (linkID != "GLOBALUNSUBSCRIBE"))
                                {
                                    if (LinkIds.Count == 0)
                                        LinkIds.Add(linkID);
                                    else
                                    {
                                        if (LinkIds.Contains(linkID) == false)
                                            LinkIds.Add(linkID);
                                    }
                                }
                            }
                        }
                        for (int i = 0; i < LinkIds.Count; i++)
                        {
                            LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(LinkIds[i].ToString()));
                            LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                            LinkDetailBase.RecipientsLinkTotalAndUniqueCounts(ConnectionString, Convert.ToInt32(mailingId), Convert.ToInt32(LinkIds[i].ToString()), out totalClickCount, out UniqueClickCount);
                            if (linkData != null)
                            {
                                if (linkData.LinkURL.ToLower().Contains("http://"))
                                    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (!linkUrlName.Contains(LinkURL))
                                    linkUrlName.Add(linkData.LinkURL);

                                totalCountValues.Add(totalClickCount);
                                uniqueCountValues.Add(UniqueClickCount);
                                if (htmlContent.ToLower().Contains(LinkIds[i].ToString()))
                                {
                                    textContent = textContent.Replace(startDelimiter[0] + LinkIds[i].ToString() + endDelimiter[0], LinkURL.ToString());
                                }
                            }
                        }
                    }

                    #endregion

                    if (textContent != string.Empty)
                    {
                        textContent = textContent.Replace("&quot;", "\"");
                        textContent = textContent.Replace("&lt;", "<");
                        textContent = textContent.Replace("&gt;", ">");
                    }
                    int totalUclicks, totalClicks;
                    totalClicks = totalUclicks = 0;
                    double TotalClickRate, UniqueClickRate;
                    TotalClickRate = UniqueClickRate = 0;
                    for (int i = 0; i < totalCountValues.Count; i++)
                    {
                        if (totalCountValues[i] == null)
                            totalCountValues[i] = 0;
                        if (uniqueCountValues[i] == null)
                            uniqueCountValues[i] = 0;
                    }
                    for (int i = 0; i < linkUrlName.Count; i++)
                    {
                        totalClicks = totalClicks + int.Parse(totalCountValues[i].ToString());
                        totalUclicks = totalUclicks + int.Parse(uniqueCountValues[i].ToString());

                    }

                    //dtExportSummary.Columns["Custom URl Links"].ColumnName = "URL";
                    DataColumn s1 = new DataColumn("URL");
                    DataColumn s2 = new DataColumn("Total Clicks");
                    DataColumn s3 = new DataColumn("Total Click rate");
                    DataColumn s4 = new DataColumn("Unique Clicks");
                    DataColumn s5 = new DataColumn("Unique Click rate");

                    dtExportSummary.Columns.Add(s1);
                    dtExportSummary.Columns.Add(s2);
                    dtExportSummary.Columns.Add(s3);
                    dtExportSummary.Columns.Add(s4);
                    dtExportSummary.Columns.Add(s5);

                    double clickRate = 0;
                    double UClickRate = 0;
                    string subStr = "";
                    if (linkUrlName.Count > 0)
                    {
                        for (int i = 0; i < linkUrlName.Count; i++)
                        {
                            if (!(linkUrlName[i].ToString() == "#") && !(linkUrlName[i].ToString().Contains('@')))
                            {
                                clickRate = Math.Round(((double)(int.Parse(totalCountValues[i].ToString()) * 100) / totalClicks), 1);
                                UClickRate = Math.Round((double)(int.Parse(uniqueCountValues[i].ToString()) * 100) / totalUclicks, 1);

                                if (linkUrlName[i].ToString().Length < 110)
                                    subStr = linkUrlName[i].ToString();
                                else
                                {
                                    subStr = linkUrlName[i].ToString().Substring(0, 110) + "...";

                                }

                                DataRow row = dtExportSummary.NewRow();
                                row[s1] = subStr;
                                row[s2] = totalCountValues[i];
                                row[s3] = (clickRate > 0 ? clickRate : 0) + "%";
                                row[s4] = uniqueCountValues[i];
                                row[s5] = (UClickRate > 0 ? UClickRate : 0) + "%";
                                dtExportSummary.Rows.Add(row);

                            }
                            TotalClickRate = TotalClickRate + (double)(int.Parse(totalCountValues[i].ToString()) * 100) / totalClicks;
                            UniqueClickRate = UniqueClickRate + (double)(int.Parse(uniqueCountValues[i].ToString()) * 100) / totalUclicks;
                        }
                        TotalClickRate = TotalClickRate > 0 ? TotalClickRate : 0;
                        UniqueClickRate = UniqueClickRate > 0 ? UniqueClickRate : 0;
                        DataRow TotalClicksRate = dtExportSummary.NewRow();
                        TotalClicksRate[s1] = "Total Clicks";
                        TotalClicksRate[s2] = totalClicks;
                        TotalClicksRate[s3] = TotalClickRate + "%";
                        TotalClicksRate[s4] = totalUclicks;
                        TotalClicksRate[s5] = UniqueClickRate + "%";
                        dtExportSummary.Rows.Add(TotalClicksRate);
                    }
                    ViewState["TempdtExportSummary"] = dtExportSummary;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void campaigns_bindcontent()
        {
            try
            {
                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(campaignID);
                CampaignMaster campMaster = CampaignMaster.SelectOne(pk, ConnectionString);
                string campaignContent;
                string editorType = Request.QueryString["EditorType"].ToString();
                if (editorType.Equals("TEXT"))
                {
                    campaignContent = campMaster.TextContent;
                    if (campaignContent.ToLower().Contains("listunsubscribe"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", System.Configuration.ConfigurationManager.AppSettings["UnSubscribeLinkPath"]);

                    }
                    if (campaignContent.ToLower().Contains("globalunsubscribe"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]",  System.Configuration.ConfigurationManager.AppSettings["UnSubscribeLinkPath"]);

                    }
                    if (campaignContent.ToLower().Contains("forwardtofriend"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]",System.Configuration.ConfigurationManager.AppSettings["ForwardToFriendLinkPath"]);

                    }
                    if (campaignContent.ToLower().Contains("mirrorweblink"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "");

                    }
                }
                else
                {
                    campaignContent = campMaster.HTMLContent;
                    if (campaignContent.ToLower().Contains("listunsubscribe"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "");

                    }
                    if (campaignContent.ToLower().Contains("globalunsubscribe"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "");

                    }
                    if (campaignContent.ToLower().Contains("forwardtofriend"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", "");

                    }
                    if (campaignContent.ToLower().Contains("mirrorweblink"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "");

                    }
                    #region this logic will add click link to the content

                    if (campaignContent.Contains("!RPLINK"))
                    {
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);
                        string LinkURL = string.Empty;
                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail = LinkDetail.SelectByField("ID", linkID);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, ConnectionString);
                                //if (linkData.LinkURL.ToLower().Contains("http://"))
                                //    linkData.LinkURL = linkData.LinkURL.Replace("http://", "");
                                LinkURL = linkData.LinkURL;
                                if (linkData != null)
                                {
                                    string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                    if (campaignContent.ToLower().Contains(linkID))
                                    {
                                        campaignContent = campaignContent.Replace(replaceToken, LinkURL);
                                    }
                                    //Create click link if recordClicks value is true
                                    //if (Convert.ToBoolean(linkData.RecordClicks))
                                    //{
                                    //    string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                                    //    content = content.Replace(replaceToken, "<A href=\"" + cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"\">" + linkData.LinkName + "</A>");
                                    //}
                                    //else
                                    //{
                                    //    string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                                    //    content = content.Replace(replaceToken, "<A href=\"" + linkData.LinkURL + "\">" + linkData.LinkName + "</A>");
                                    //}
                                }
                            }

                        }

                    }

                    #endregion
                }
                contentdiv.InnerHtml = campaignContent;

            }
            catch (Exception ex)
            {
            }
        }
Пример #13
0
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="LinkDetailPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class LinkDetail</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			12/16/2009 3:09:15 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static LinkDetail SelectOne(LinkDetailPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key, nvc[key]);
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr = oDatabaseHelper.ExecuteReader("sp_LinkDetails_SelectbyPrimaryKey", ref ExecutionState);
            if (dr.Read())
            {
                LinkDetail obj = new LinkDetail(ConnectionString);
                PopulateObjectFromReader(obj, dr);
                dr.Close();
                oDatabaseHelper.Dispose();
                return obj;
            }
            else
            {
                dr.Close();
                oDatabaseHelper.Dispose();
                return null;
            }
        }
Пример #14
0
        /// <summary>
        /// This method will Delete one row from the database using the primary key information
        /// </summary>
        ///
        /// <param name="pk" type="LinkDetailPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>True if succeeded</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			12/16/2009 3:09:15 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static bool Delete(LinkDetailPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key, nvc[key]);
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            oDatabaseHelper.ExecuteScalar("sp_LinkDetails_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return ExecutionState;
        }
Пример #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["LinkID"] != null || Request.QueryString["ContactID"] != null && Request.QueryString["CampaignID"] != null && Request.QueryString["Username"] != null)
            {
                try
                {
                    //get cleint database credentials.
                    userName = Request.QueryString["Username"].ToString();
                    ProfileBase objProfileBase = ProfileBase.Create(userName, true);
                    string dbName = objProfileBase.GetPropertyValue("DBName").ToString();
                    string dbUserID = objProfileBase.GetPropertyValue("DBUserID").ToString();
                    string dbPassword = objProfileBase.GetPropertyValue("DBPassword").ToString();
                    string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();

                    connectionString =
                       string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Pooling=True",
                                     dbServerName, dbName, dbUserID, dbPassword);
                    ConnectionStringHelper.ConStr = connectionString;

                    string userAgent = Request.UserAgent;
                    string ipAddress = Request.UserHostAddress;
                    insertLinkClickedDetails(Convert.ToInt64(Request.QueryString["LinkID"]), Convert.ToInt64(Request.QueryString["ContactID"]), Convert.ToInt64(Request.QueryString["CampaignID"]), ipAddress, userAgent);

                    LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(Request.QueryString["LinkID"]));
                    LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString);

                    string strAMMLink = "http://" + ConfigurationManager.AppSettings["NewAMMLink"].ToString();
                    string strWheelockLink = "http://" + ConfigurationManager.AppSettings["WheelockLink"].ToString();
                    string strWidenerLink = "http://" + ConfigurationManager.AppSettings["WidenerLink"].ToString();
                    string linkUrl = linkData.LinkURL;

                    if (linkUrl.Contains("&amp;"))
                    {
                        linkUrl = linkUrl.Replace("&amp;", "&");
                    }

                    if (linkUrl.Contains("["))
                    {
                        //ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(Request.QueryString["ContactID"]));
                        //ContactMaster contMaster = ContactMaster.SelectOne(pk, connectionString);
                        DataTable dtCon = ContactMasterBase.getSelectedContact(Convert.ToInt64(Request.QueryString["ContactID"]), connectionString);

                        if (linkUrl.Contains("[!LastName!]"))
                        {
                            linkUrl = linkUrl.Replace("[!LastName!]", dtCon.Rows[0]["LastName"].ToString());
                        }
                        if (linkUrl.Contains("[!FirstName!]"))
                        {
                            linkUrl = linkUrl.Replace("[!FirstName!]", dtCon.Rows[0]["FirstName"].ToString());
                        }
                        if (linkUrl.Contains("[!EmailAddress!]"))
                        {
                            linkUrl = linkUrl.Replace("[!EmailAddress!]", dtCon.Rows[0]["EmailAddress"].ToString());
                        }

                        DataTable customFieldDt = ManageFieldsBase.getPersonalizedCustomFields(connectionString);
                        for (int i = 0; i < customFieldDt.Rows.Count; i++)
                        {
                            string startChars = "[!";
                            string endChars = "!]";
                            string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                            string customColName;
                            if (linkUrl.Contains(strCustomCtrl))
                            {
                                customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                                //linkData.LinkURL = linkData.LinkURL.Replace(strCustomCtrl, drContact[customColName].ToString());
                                linkUrl = linkUrl.Replace(strCustomCtrl, dtCon.Rows[0][customColName].ToString());
                            }
                        }
                    }

                    if (linkUrl == "http://mta1.1pointinteractive.com/Marketer_EmailTracker/AMMForm.aspx")
                    {
                        Response.Redirect(linkUrl + "?ContactID=" + Request.QueryString["ContactID"].ToString().Trim() + "&CampaignID=" + Request.QueryString["CampaignID"].ToString().Trim() + "&Username="******"Username"].ToString().Trim(), false);
                    }
                    else if (linkUrl == strAMMLink.ToString())//http://www.ammedu.net/Marketer_EmailTracker/AMMForm2.aspx
                    {
                        Response.Redirect(linkUrl + "?ContactID=" + Request.QueryString["ContactID"].ToString().Trim() + "&CampaignID=" + Request.QueryString["CampaignID"].ToString().Trim() + "&Username="******"Username"].ToString().Trim(), false);
                    }
                    else if (linkUrl == strWheelockLink.ToString())//http://www.ammedu.net/Marketer_EmailTracker/WheelockForm.aspx
                    {
                        Response.Redirect(linkUrl + "?ContactID=" + Request.QueryString["ContactID"].ToString().Trim() + "&CampaignID=" + Request.QueryString["CampaignID"].ToString().Trim() + "&Username="******"Username"].ToString().Trim(), false);
                    }
                    else if (linkUrl == strWidenerLink.ToString())//http://www.ammedu.net/Marketer_EmailTracker/WidenerForm.aspx
                    {
                        Response.Redirect(linkUrl + "?ContactID=" + Request.QueryString["ContactID"].ToString().Trim() + "&CampaignID=" + Request.QueryString["CampaignID"].ToString().Trim() + "&Username="******"Username"].ToString().Trim(), false);
                    }
                    else
                    {

                        if (linkUrl.ToLower().Contains("http://"))
                            Response.Redirect(linkUrl, false);
                        else
                            Response.Redirect("http://" + linkUrl, false);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        public void campaigns_bindcontent()
        {
            try
            {
                contactID = Convert.ToInt64(Request.QueryString["ContactID"]);
                ContactMasterPrimaryKey cpk = new ContactMasterPrimaryKey(contactID);
                ContactMaster contact = ContactMaster.SelectOne(cpk, connectionString);

                CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(campaignID);
                CampaignMaster campMaster = CampaignMaster.SelectOne(pk, connectionString);
                string campaignContent = "";
                //if (campMaster.HTMLContent != "")
                campaignContent = campMaster.HTMLContent;
                //else
                //    campaignContent = campMaster.TextContent;

                if (Request.QueryString["ForwardedEmail"] != null)
                {
                    #region handle standard links

                    if (campaignContent.Contains("[!RPLINK:LISTUNSUBSCRIBE!]"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "");//"<A style=\"cursor:default;color:Gray\" href=\"#\">List UnSubscribe</A>");
                    }

                    if (campaignContent.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("Global Unsubscribe"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("Global Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("Unsubscribe"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }
                    if (campaignContent.Contains("If you no longer wish to receive these emails, simply click on the following link:"))
                    {
                        //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("If you no longer wish to receive these emails, simply click on the following link:", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                    }

                    if (campaignContent.ToLower().Contains("forwardtofriend"))
                    {
                        string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", forwardttofriendLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&Email=" + contact.EmailAddress.ToString() + "&Username="******"mirrorweblink"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "#");
                    }
                    if (campaignContent.ToLower().Contains("amm"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:AMM!]", "#");
                    }
                    if (campaignContent.ToLower().Contains("amm2"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:AMM2!]", "#");
                    }

                    #endregion

                    //Replace pesonalise fields from the content.
                    #region this logic will replaces personalised fields.
                    Int64 CampaignId = Convert.ToInt64(Request.QueryString["CampaignID"]);
                    Int64 ContactId = Convert.ToInt64(Request.QueryString["ContactID"]);
                    string EmailAddress = Request.QueryString["ForwardedEmail"].ToString();

                    string sqlQry ="SELECT *  FROM [ForwardDetails] where [CampaignID]=" + CampaignId + " and [EmailAddress]='" + EmailAddress + "' and [ContactID]=" + ContactId + " ";
                    ds = getDataset(sqlQry);
                    DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(connectionString);

                    if (campaignContent.Contains("[!LastName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!LastName!]", ds.Tables[0].Rows[0]["LastName"].ToString());
                    }

                    if (campaignContent.Contains("[!FirstName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!FirstName!]", ds.Tables[0].Rows[0]["FirstName"].ToString());
                    }

                    if (campaignContent.Contains("[!EmailAddress!]"))
                    {
                        campaignContent = campaignContent.Replace("[!EmailAddress!]", ds.Tables[0].Rows[0]["EmailAddress"].ToString());
                    }

                    for (int i = 0; i < customFieldDt.Rows.Count; i++)
                    {
                        string startChars = "[!";
                        string endChars = "!]";
                        string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                        string customColName;
                        if (campaignContent.Contains(strCustomCtrl))
                        {
                            customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                            campaignContent = campaignContent.Replace(strCustomCtrl, ds.Tables[0].Rows[0][customColName].ToString());

                        }
                    }

                    #endregion

                    //Add click link to the content.
                    #region this logic will add click link to the content

                    if (campaignContent.Contains("!RPLINK"))
                    {
                        string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);

                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString);

                                if (linkData != null)
                                {
                                    //Create click link if recordClicks value is true

                                    if (Convert.ToBoolean(linkData.RecordClicks))
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + Convert.ToInt32(Request.QueryString["ContactID"]) + "&CampaignID=" + campaignID + "&Username="******"listunsubscribe"))
                    {
                        string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", unsubscribeLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&ListUnSub=YES" + "&Username="******"globalunsubscribe"))
                    {
                        string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", unsubscribeLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&GlobalUnSub=YES" + "&Username="******"forwardtofriend"))
                    {
                        string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString();
                        campaignContent = campaignContent.Replace("[!RPLINK:FORWARDTOFRIEND!]", forwardttofriendLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&Email=" + contact.EmailAddress.ToString() + "&Username="******"mirrorweblink"))
                    {
                        campaignContent = campaignContent.Replace("[!RPLINK:MIRRORWEBLINK!]", "#");
                    }

                    #endregion

                    //Replace pesonalise fields from the content.
                    #region this logic will replaces personalised fields.

                    string sqlQry = " select * from ContactMaster where ContactId=" + Convert.ToInt32(Request.QueryString["ContactID"]);
                    ds = getDataset(sqlQry);
                    DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(connectionString);

                    if (campaignContent.Contains("[!LastName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!LastName!]", ds.Tables[0].Rows[0]["LastName"].ToString());
                    }

                    if (campaignContent.Contains("[!FirstName!]"))
                    {
                        campaignContent = campaignContent.Replace("[!FirstName!]", ds.Tables[0].Rows[0]["FirstName"].ToString());
                    }

                    if (campaignContent.Contains("[!EmailAddress!]"))
                    {
                        campaignContent = campaignContent.Replace("[!EmailAddress!]", ds.Tables[0].Rows[0]["EmailAddress"].ToString());
                    }

                    for (int i = 0; i < customFieldDt.Rows.Count; i++)
                    {
                        string startChars = "[!";
                        string endChars = "!]";
                        string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                        string customColName;
                        if (campaignContent.Contains(strCustomCtrl))
                        {
                            customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                            campaignContent = campaignContent.Replace(strCustomCtrl, ds.Tables[0].Rows[0][customColName].ToString());

                        }
                    }

                    #endregion

                    //Add click link to the content.
                    #region this logic will add click link to the content

                    if (campaignContent.Contains("!RPLINK"))
                    {
                        string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = campaignContent.Split(startDelimiter, StringSplitOptions.None);

                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString);

                                if (linkData != null)
                                {
                                    //Create click link if recordClicks value is true

                                    if (Convert.ToBoolean(linkData.RecordClicks))
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + Convert.ToInt32(Request.QueryString["ContactID"]) + "&CampaignID=" + campaignID + "&Username=" + userName);
                                    }
                                    else
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];

                                        campaignContent = campaignContent.Replace(replaceToken, linkData.LinkURL);
                                    }
                                }
                            }

                        }

                    }

                    #endregion

                }

                contentdiv.InnerHtml = campaignContent;

            }
            catch (Exception ex)
            {
            }
        }
        private string personalizeContent(DataRow drContact, string content, string trackReads)
        {
            try
            {
                Logger.logdata(logforemailbuilder, "************** in personalizeContent(..) method **************");
                Logger.logdata(logforemailbuilder, string.Format("personalizeContent(..) has been started at {0}", DateTime.Now.ToString()));

                //Add links maually for testing
                //comment out below lines after testing
                //content = "<br/>Hi<br/>[!FirstName!]" + content;
                //content += string.Format("<br/>{0}<br/>{1}<br/>{2}<br/>{3}<br/>{4}<br/>", "[!RPLINK:1!]", "[!RPLINK:9!]", "[!RPLINK:LISTUNSUBSCRIBE!]", "[!RPLINK:GLOBALUNSUBSCRIBE!]", "[!RPLINK:FORWARDTOFRIEND!]");

                //Adding yahoo and google links manually, comment out after testing.
                //content += "<br/>[!RPLINK:1!]<br/>[!RPLINK:2!]<br/>";

                //Add open link to the content.
                #region this logic will add open link to the content
                string openLinkPath = ConfigurationManager.AppSettings["OpenLinkPath"].ToString();
                content += "<img src=\"" + openLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"\" width=1 height=1 border=0>";
                #endregion

                //Replace personalized fields if any in the content.
                if (!string.IsNullOrEmpty(content))
                {
                    //Add list Forward to Friend link to the content.
                    #region this logic will add list Forward to Friend link to the content
                    if (content.Contains("[!RPLINK:FORWARDTOFRIEND!]"))
                    {
                        string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString();
                        content = content.Replace("[!RPLINK:FORWARDTOFRIEND!]", "<A href=\"" + forwardttofriendLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Email=" + drContact["EmailAddress"].ToString() + "&Username="******"\">Forward To Friend</A>");
                    }
                    #endregion

                    //Add list unsubscribe link to the content.
                    #region this logic will add list unsubscribe link to the content
                    if (content.Contains("[!RPLINK:LISTUNSUBSCRIBE!]"))
                    {
                        string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        content = content.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "<A href=\"" + unsubscribeLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&ListUnSub=YES" + "&Username="******"\">List UnSubscribe</A>");
                    }
                    #endregion

                    //Add global unsubscribe link to the content.
                    #region this logic will add list unsubscribe link to the content
                    if (content.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                    {
                        string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                        content = content.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "<A href=\"" + unsubscribeLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&GlobalUnSub=YES" + "&Username="******"\">Global UnSubscribe</A>");
                    }
                    #endregion

                    //Add list mirror link to the content
                    #region this logic will add list Mirror link to the content
                    if (content.Contains("[!RPLINK:MIRRORWEBLINK!]"))
                    {
                        string MirrorLinkPath = ConfigurationManager.AppSettings["ClickHearURL"].ToString();
                        content = content.Replace("[!RPLINK:MIRRORWEBLINK!]", "<A href=\"" + MirrorLinkPath + "?ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&type=campaign" + "&Username="******"\">click here</A>");
                    }
                    #endregion

                    //Add click link to the content.
                    #region this logic will add click link to the content

                    if (content.Contains("!RPLINK"))
                    {
                        string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                        string[] startDelimiter = new string[] { "[!RPLINK:" };
                        string[] endDelimiter = new string[] { "!]" };
                        string[] splittedContent = content.Split(startDelimiter, StringSplitOptions.None);

                        for (int i = 1; i < splittedContent.Length; i++)
                        {
                            string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                            //get linkDetails using linkID.
                            //LinkDetails objLinkDetail1 = LinkDetail.SelectByField("ID", linkID, connectionString);
                            if (!string.IsNullOrEmpty(linkID))
                            {
                                LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));//linkID
                                LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, connectionString);

                                if (linkData != null)
                                {
                                    //Create click link if recordClicks value is true
                                    if (Convert.ToBoolean(linkData.RecordClicks))
                                    {
                                        string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                                        if (trackReads.ToString() == "True")
                                            //content = content.Replace(replaceToken, "<A href=\"" + cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"\">" + linkData.LinkName + "</A>");
                                            content = content.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"http://" + linkData.LinkName);
                                            content = content.Replace(replaceToken, linkData.LinkURL);
                                        //content = content.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"<A href=\"" + linkData.LinkURL + "\">" + linkData.LinkName + "</A>");
                                        content = content.Replace(replaceToken, linkData.LinkURL);

                                    }
                                }
                            }

                        }

                    }

                    #endregion

                    //Replace pesonalise fields from the content.
                    #region this logic will replaces personalised fields.
                    if (content.Contains("[!LastName!]"))
                    {
                        content = content.Replace("[!LastName!]", drContact["LastName"].ToString());
                    }

                    if (content.Contains("[!FirstName!]"))
                    {
                        content = content.Replace("[!FirstName!]", drContact["FirstName"].ToString());
                    }

                    if (content.Contains("[!EmailAddress!]"))
                    {
                        content = content.Replace("[!EmailAddress!]", drContact["EmailAddress"].ToString());
                    }

                    DataTable customFieldDt = ManageFieldsBase.SelectCustomFields(connectionString);
                    for (int i = 0; i < customFieldDt.Rows.Count; i++)
                    {
                        string startChars = "[!";
                        string endChars = "!]";
                        string strCustomCtrl = startChars + customFieldDt.Rows[i]["FieldName"].ToString() + endChars;
                        string customColName;
                        if (content.Contains(strCustomCtrl))
                        {
                            //alCustonFields.Add(customFieldDt.Rows[i]["ContactFieldName"].ToString());
                            customColName = customFieldDt.Rows[i]["ContactFieldName"].ToString();
                            content = content.Replace(strCustomCtrl, drContact[customColName].ToString());
                        }
                    }
                    #endregion
                    Logger.logdata(logforemailbuilder, string.Format("personalizeContent(..) method has been ended at {0}", DateTime.Now.ToString()));
                    Logger.logdata(logforemailbuilder, "************** Exit personalizeContent(..) method **************");
                    return content;
                }
                else
                {
                    Logger.logdata(logforemailbuilder, string.Format("personalizeContent(..) method has been ended at {0}", DateTime.Now.ToString()));
                    Logger.logdata(logforemailbuilder, "************** Exit personalizeContent(..) method **************");
                    return content;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private string personalizeContent(DataRow drContact, string content)
        {
            //Add links maually for testing
            //comment out below lines after testing
            //content = "<br/>Hi<br/>[!FirstName!]" + content;
            //content += string.Format("<br/>{0}<br/>{1}<br/>{2}<br/>{3}", "[!RPLINK:1!]", "[!RPLINK:9!]", "[!RPLINK:LISTUNSUBSCRIBE!]", "[!RPLINK:GLOBALUNSUBSCRIBE!]");

            //Add the subscrinbe link to the  email content.
            string subscribeLinkPath = ConfigurationManager.AppSettings["SubscribeLinkPath"].ToString();
            string subscribeLink = "<A href=\"" + subscribeLinkPath + "?Email=" + drContact["EmailAddress"].ToString() + "&ContactID=" + contactID + "&CampaignID=" + campaignID + "&Username="******"\">Click here</A>";
            content = string.Format("This email was forwarded to you by {0}. <br/>", sendersEmail) + string.Format("{0}. <br/>", customMessage) + string.Format("{0} if you would like to subscribe to this list. <br/>", subscribeLink) + content;

            //Add open link to the content.
            #region this logic will add open link to the content
            string openLinkPath = ConfigurationManager.AppSettings["OpenLinkPath"].ToString();
            content += "<img src=\"" + openLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&Username="******"\" width=1 height=1 border=0>";
            #endregion

            //Replace personalized fields if any in the content.
            if (!string.IsNullOrEmpty(content))
            {
                //Add list Forward to Friend link to the content.
                #region this logic will add list Forward to Friend link to the content
                if (content.Contains("[!RPLINK:FORWARDTOFRIEND!]"))
                {
                    string forwardttofriendLinkPath = ConfigurationManager.AppSettings["ForwardToFriendLinkPath"].ToString();
                    content = content.Replace("[!RPLINK:FORWARDTOFRIEND!]", forwardttofriendLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&Email=" + drContact["EmailAddress"].ToString() + "&Username="******"[!RPLINK:LISTUNSUBSCRIBE!]"))
                {
                    //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                    content = content.Replace("[!RPLINK:LISTUNSUBSCRIBE!]", "");//"<A style=\"cursor:default;color:Gray\" href=\"#\">List UnSubscribe</A>");
                }
                #endregion

                //Add global unsubscribe link to the content.
                #region this logic will add list unsubscribe link to the content
                if (content.Contains("[!RPLINK:GLOBALUNSUBSCRIBE!]"))
                {
                    //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                    content = content.Replace("[!RPLINK:GLOBALUNSUBSCRIBE!]", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                }
                if (content.Contains("Global Unsubscribe"))
                {
                    //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                    content = content.Replace("Global Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                }
                if (content.Contains("List Unsubscribe"))
                {
                    //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                    content = content.Replace("List Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                }
               if (content.Contains("Unsubscribe"))
                {
                    //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                    content = content.Replace("Unsubscribe", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                }

               if (content.Contains("If you no longer wish to receive these emails, simply click on the following link:"))
                {
                    //string unsubscribeLinkPath = ConfigurationManager.AppSettings["UnSubscribeLinkPath"].ToString();
                    content = content.Replace("If you no longer wish to receive these emails, simply click on the following link:", "");// "<A style=\"cursor:default;color:Gray\" href=\"#\">Global UnSubscribe</A>");
                }

                #endregion

                #region this logic will add list Mirror link to the content
                if (content.Contains("[!RPLINK:MIRRORWEBLINK!]"))
                {
                    string MirrorLinkPath = ConfigurationManager.AppSettings["ClickHearURL"].ToString();
                    content = content.Replace("[!RPLINK:MIRRORWEBLINK!]", MirrorLinkPath + "?ContactID=" + contactID + "&CampaignID=" + campaignID + "&type=campaign" + "&Username="******"&ForwardedEmail=" + drContact["EmailAddress"].ToString());
                }
                #endregion

                //Add click link to the content.
                #region this logic will add click link to the content

                if (content.Contains("!RPLINK"))
                {
                    string cliclLinkPath = ConfigurationManager.AppSettings["ClickLinkPath"].ToString();
                    string[] startDelimiter = new string[] { "[!RPLINK:" };
                    string[] endDelimiter = new string[] { "!]" };
                    string[] splittedContent = content.Split(startDelimiter, StringSplitOptions.None);

                    for (int i = 1; i < splittedContent.Length; i++)
                    {
                        string linkID = splittedContent[i].Split(endDelimiter, StringSplitOptions.None)[0];
                        //get linkDetails using linkID.
                        //LinkDetails objLinkDetail = LinkDetail.SelectByField("ID", linkID);
                        LinkDetailPrimaryKey objLinkDetail = new LinkDetailPrimaryKey(Convert.ToInt64(linkID));
                        LinkDetail linkData = LinkDetail.SelectOne(objLinkDetail, clientConnectionString);
                        //Create click link if recordClicks value is true
                        if (Convert.ToBoolean(linkData.RecordClicks))
                        {
                            string replaceToken = startDelimiter[0] + linkID + endDelimiter[0];
                            //content = content.Replace(replaceToken, "<A href=\"" + cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + contactID + "&CampaignID=" + campaignID + "&Username="******"\">" + linkData.LinkName + "</A>");
                            content = content.Replace(replaceToken, cliclLinkPath + "?LinkID=" + linkID + "&ContactID=" + drContact["ContactId"] + "&CampaignID=" + campaignID + "&Username="******"<A href=\"" + linkData.LinkURL + "\">" + linkData.LinkName + "</A>");
                            content = content.Replace(replaceToken, linkData.LinkURL);
                        }
                    }

                }

                #endregion

                //Replace pesonalise fields from the content.
                #region this logic will replaces personalised fields.
                if (content.Contains("[!LastName!]"))
                {
                    content = content.Replace("[!LastName!]", drContact["LastName"].ToString());
                }

                if (content.Contains("[!FirstName!]"))
                {
                    content = content.Replace("[!FirstName!]", drContact["FirstName"].ToString());
                }

                if (content.Contains("[!EmailAddress!]"))
                {
                    content = content.Replace("[!EmailAddress!]", drContact["EmailAddress"].ToString());
                }
                #endregion

                return content;
            }
            else
            {
                return content;
            }
        }