Beispiel #1
0
 //Ganesh on 30nov09
 //This method will insert a new job in CampaignJob table.
 public void insertCampainJob(CampaignMaster objCampaignMaster, string ScheduledTime, string sendType, Int64 campaignMasterID)
 {
     CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
         objCampaignJob.CampaignMasterID = campaignMasterID;
         objCampaignJob.CreatedDatetime = DateTime.Now;
         objCampaignJob.ScheduledDatetime = Convert.ToDateTime(ScheduledTime);
         objCampaignJob.SendType = sendType;
         objCampaignJob.Status = 1;
         objCampaignJob.Insert();
 }
        public XmlDocument AddCampaign(string UserID, string Password, string CampName, string FromAdd, string FromName, string ReplyEmailAdd, string Subject, int TempId, string ListIds, DateTime LaunchDateTime)
        {
            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            str.Append("<CampaignInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);
            if (ConnectionString.Trim().Length != 0 && CampName.Trim().Length != 0 && FromAdd.Trim().Length != 0 && FromName.Trim().Length != 0 && Subject.Trim().Length != 0 && ReplyEmailAdd.Trim().Length != 0 && TempId != 0 && ListIds.Trim().Length != 0 && LaunchDateTime != null)//(Convert.ToDateTime(LaunchDateTime) > DateTime.Now))
            {
                //ListMasters list = ListMaster.SelectByField("ListName", ListName, ConnectionString);
                CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", CampName, ConnectionString);
                if (camp.Count > 0)
                {
                    str.Append("<Message>Campaign Name AllRedy Existed</Message>");
                }
                else
                {
                    TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TempId);
                    TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
                    if (tempMaster != null)
                    {
                        CampaignMaster objCampaignMaster = new CampaignMaster(ConnectionString);
                        objCampaignMaster.CampaignName = CampName;
                        objCampaignMaster.CampaignDescription = "";
                        objCampaignMaster.FromAddress = FromAdd;
                        objCampaignMaster.FromName = FromName;
                        objCampaignMaster.ReplytoAddress = ReplyEmailAdd;
                        objCampaignMaster.ReplaytoName = "";
                        objCampaignMaster.Subject = Subject;
                        objCampaignMaster.TrackReads = true;//"1";
                        objCampaignMaster.SelectCondition = ListIds;
                        objCampaignMaster.TemplateId = TempId;

                        objCampaignMaster.ModifiedDate = DateTime.Now;
                        objCampaignMaster.CreatedDate = DateTime.Now;

                        objCampaignMaster.HTMLContent = tempMaster.HTMLContent;
                        objCampaignMaster.TextContent = "";
                        objCampaignMaster.SuppressDomain = "";
                        Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                        if (campaignMasterID > 0)
                        {
                            CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                            objCampaignJob.CampaignMasterID = campaignMasterID;
                            objCampaignJob.CreatedDatetime = DateTime.Now;
                            objCampaignJob.ScheduledDatetime = LaunchDateTime.AddMinutes(2);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
                            objCampaignJob.SendType = "IMMEDIATE";
                            objCampaignJob.Status = 1;
                            objCampaignJob.Insert();
                        }
                        str.Append("<Message>Campaign Inserted Succefully</Message>");
                    }
                    else
                    {
                        str.Append("<Message>Enter Valid TemplateId</Message>");
                    }
                }
            }
            else
            {
                str.Append("<Message>Enter Valid Inputs</Message>");
            }
            str.Append("</CampaignInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
Beispiel #3
0
        public string ScheduleMailingWithSuppressList(string Con, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, string ListID, string SupListId, string SeedId, string scheduleTime, string sendType)
        {
            TemplateMaster tempMaster = null;
            try
            {
                long listid = 0;
                TemplateMasters obj = TemplateMaster.SelectByField("TemplateName", TemplateName, Con);
                if (obj.Count > 0)
                {
                    TemplateMasterPrimaryKey template = new TemplateMasterPrimaryKey(Convert.ToInt64(obj[0].TemplateId.ToString()));
                    tempMaster = TemplateMaster.SelectOne(template, Con);
                    CampaignMaster objCampaignMaster = new CampaignMaster(Con);
                    objCampaignMaster.CampaignName = CampaignName;
                    objCampaignMaster.CampaignDescription = "";
                    objCampaignMaster.FromAddress = FromAddress;
                    objCampaignMaster.FromName = FromName;
                    objCampaignMaster.ReplytoAddress = ReplyToAddress;
                    objCampaignMaster.ReplaytoName = FromName;
                    objCampaignMaster.Subject = Subject;
                    objCampaignMaster.TrackReads = true;//"1";
                    objCampaignMaster.SelectCondition = ListID;
                    objCampaignMaster.TemplateId = tempMaster.TemplateId;
                    objCampaignMaster.ModifiedDate = DateTime.Now;
                    objCampaignMaster.CreatedDate = DateTime.Now;
                    objCampaignMaster.HTMLContent = tempMaster.HTMLContent;
                    objCampaignMaster.TextContent = "";
                    objCampaignMaster.SuppressDomain = "";
                    objCampaignMaster.UnsubscribeText = "If you no longer wish to receive these emails, simply click on the following link:";
                    objCampaignMaster.UnsubscribeLinkText = "Unsubscribe";
                    objCampaignMaster.AssignedCampaignID = 0;
                    objCampaignMaster.SuppressSelection = SupListId.ToString();
                    objCampaignMaster.htmlHasUnsubLink = true;
                    objCampaignMaster.txtHasUnsubLink = false;

                    Int64 campaignMasterID = objCampaignMaster.insertMailing(objCampaignMaster);
                    if (campaignMasterID > 0)
                    {
                        CampaignJob objCampaignJob = new CampaignJob(Con);
                        objCampaignJob.CampaignMasterID = campaignMasterID;
                        objCampaignJob.CreatedDatetime = DateTime.Now;
                        objCampaignJob.ScheduledDatetime = Convert.ToDateTime(scheduleTime);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
                        Logger.logdata(logforRpService, "Mailing Schedule Date Time :" + scheduleTime + "");
                        objCampaignJob.SendType = sendType;
                        objCampaignJob.Status = 5;
                        objCampaignJob.Insert();

                    }
                    Logger.logdata(logforRpService, "Mailing Inserted Succefully");
                    return (campaignMasterID.ToString());
                }
                else
                {
                    return ("False");
                }

            }
            catch (Exception ex)
            {
                Logger.logdata(logforRpService, ex.Message);
                return ("False");
            }


        }
Beispiel #4
0
        //[WebMethod(EnableSession = true)]
        //public XmlDocument SendCampaign(string UserID, string Password, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, DataSet ds)
        //{
        //    StringBuilder str = new StringBuilder();
        //    try
        //    {

        //        string Con = GetConnectionString(UserID, Password);
        //        #region Contacts
        //        str.Append("<CampaignDetails>");
        //        LogStartInfo("AddRecipient", Con, UserID);
        //        DataTable contacts = ds.Tables[0];
        //        string ContactIds = "";
        //        if (Con.Trim().Length != 0)
        //        {
        //            if (contacts.Rows.Count > 0 && !(contacts.Columns.IndexOf("EmailAddress") == -1))
        //            {
        //                Logger.logdata(logforRpService, "SendCampaign() at Contacts region");
        //                foreach (DataRow contact in contacts.Rows)
        //                {
        //                    ContactMasters contemail = ContactMaster.SelectByField("EmailAddress", contact["EmailAddress"].ToString(), Con);


        //                    if (contemail.Count > 0)
        //                    {
        //                        try
        //                        {
        //                            ContactIds = ContactIds + contemail[0].ContactId.ToString() + ",";
        //                            ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(contemail[0].ContactId.ToString()));
        //                            ContactMaster objContactMaster = ContactMaster.SelectOne(pk, Con);
        //                            objContactMaster.FirstName = contact["FirstName"].ToString();
        //                            objContactMaster.LastName = contact["LastName"].ToString();
        //                            #region Handling Custom fields

        //                            foreach (DataColumn column in contacts.Columns)
        //                            {
        //                                DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, Con);
        //                                string custField = "";
        //                                if (customFieldDt.Rows.Count > 0)
        //                                {
        //                                    custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
        //                                }
        //                                if (custField != "" && customFieldDt.Rows.Count > 0 && contact[column.ColumnName] != "")
        //                                {
        //                                    switch (custField)
        //                                    {
        //                                        case "CustomField1":
        //                                            objContactMaster.CustomField1 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField2":
        //                                            objContactMaster.CustomField2 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField3":
        //                                            objContactMaster.CustomField3 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField4":
        //                                            objContactMaster.CustomField4 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField5":
        //                                            objContactMaster.CustomField5 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField6":
        //                                            objContactMaster.CustomField6 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField7":
        //                                            objContactMaster.CustomField7 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField8":
        //                                            objContactMaster.CustomField8 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField9":
        //                                            objContactMaster.CustomField9 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField10":
        //                                            objContactMaster.CustomField10 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField11":
        //                                            objContactMaster.CustomField11 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField12":
        //                                            objContactMaster.CustomField12 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField13":
        //                                            objContactMaster.CustomField13 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField14":
        //                                            objContactMaster.CustomField14 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField15":
        //                                            objContactMaster.CustomField15 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField16":
        //                                            objContactMaster.CustomField16 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField17":
        //                                            objContactMaster.CustomField17 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField18":
        //                                            objContactMaster.CustomField18 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField19":
        //                                            objContactMaster.CustomField19 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField20":
        //                                            objContactMaster.CustomField20 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField21":
        //                                            objContactMaster.CustomField21 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField22":
        //                                            objContactMaster.CustomField22 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField23":
        //                                            objContactMaster.CustomField23 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField24":
        //                                            objContactMaster.CustomField24 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField25":
        //                                            objContactMaster.CustomField25 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField26":
        //                                            objContactMaster.CustomField26 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField27":
        //                                            objContactMaster.CustomField27 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField28":
        //                                            objContactMaster.CustomField28 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField29":
        //                                            objContactMaster.CustomField29 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField30":
        //                                            objContactMaster.CustomField30 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField31":
        //                                            objContactMaster.CustomField31 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField32":
        //                                            objContactMaster.CustomField32 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField33":
        //                                            objContactMaster.CustomField33 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField34":
        //                                            objContactMaster.CustomField34 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField35":
        //                                            objContactMaster.CustomField35 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField36":
        //                                            objContactMaster.CustomField36 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField37":
        //                                            objContactMaster.CustomField37 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField38":
        //                                            objContactMaster.CustomField38 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField39":
        //                                            objContactMaster.CustomField39 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField40":
        //                                            objContactMaster.CustomField40 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField41":
        //                                            objContactMaster.CustomField41 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField42":
        //                                            objContactMaster.CustomField42 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField43":
        //                                            objContactMaster.CustomField43 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField44":
        //                                            objContactMaster.CustomField44 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField45":
        //                                            objContactMaster.CustomField45 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField46":
        //                                            objContactMaster.CustomField46 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField47":
        //                                            objContactMaster.CustomField47 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField48":
        //                                            objContactMaster.CustomField48 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField49":
        //                                            objContactMaster.CustomField49 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField50":
        //                                            objContactMaster.CustomField50 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                    }
        //                                }


        //                            }

        //                            #endregion
        //                            if (objContactMaster.Update() == true)
        //                            {
        //                                //str.Append("<Message>Recipient Updated Successfully</Message>");
        //                                Logger.logdata(logforRpService, "Recipient Updated Successfully");
        //                            }
        //                            else
        //                            {
        //                                //str.Append("<Error>Recipient  Update Failed</Error>");
        //                                Logger.logdata(logforRpService, "Recipient  Update Failed");
        //                            }

        //                        }
        //                        catch (Exception ex)
        //                        {
        //                            str.Append("<Error>Edit Contact: Problem at updating contact</Error>");
        //                            Logger.logdata(logforRpService, ex.Message);

        //                        }


        //                    }
        //                    else
        //                    {
        //                        try
        //                        {
        //                            ContactMaster objContactMaster = new ContactMaster(Con);
        //                            objContactMaster.EmailAddress = contact["EmailAddress"].ToString(); ;
        //                            objContactMaster.EmailContentType = "Html";
        //                            objContactMaster.CreatedDate = DateTime.Now;
        //                            objContactMaster.FirstName = contact["FirstName"].ToString();
        //                            objContactMaster.LastName = contact["LastName"].ToString();
        //                            #region Handling Custom fields

        //                            foreach (DataColumn column in contacts.Columns)
        //                            {
        //                                DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, Con);
        //                                string custField = "";
        //                                if (customFieldDt.Rows.Count > 0)
        //                                {
        //                                    custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
        //                                }
        //                                if (custField != "" && customFieldDt.Rows.Count > 0 && contact[column.ColumnName] != "")
        //                                {
        //                                    switch (custField)
        //                                    {
        //                                        case "CustomField1":
        //                                            objContactMaster.CustomField1 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField2":
        //                                            objContactMaster.CustomField2 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField3":
        //                                            objContactMaster.CustomField3 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField4":
        //                                            objContactMaster.CustomField4 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField5":
        //                                            objContactMaster.CustomField5 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField6":
        //                                            objContactMaster.CustomField6 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField7":
        //                                            objContactMaster.CustomField7 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField8":
        //                                            objContactMaster.CustomField8 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField9":
        //                                            objContactMaster.CustomField9 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField10":
        //                                            objContactMaster.CustomField10 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField11":
        //                                            objContactMaster.CustomField11 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField12":
        //                                            objContactMaster.CustomField12 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField13":
        //                                            objContactMaster.CustomField13 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField14":
        //                                            objContactMaster.CustomField14 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField15":
        //                                            objContactMaster.CustomField15 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField16":
        //                                            objContactMaster.CustomField16 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField17":
        //                                            objContactMaster.CustomField17 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField18":
        //                                            objContactMaster.CustomField18 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField19":
        //                                            objContactMaster.CustomField19 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField20":
        //                                            objContactMaster.CustomField20 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField21":
        //                                            objContactMaster.CustomField21 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField22":
        //                                            objContactMaster.CustomField22 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField23":
        //                                            objContactMaster.CustomField23 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField24":
        //                                            objContactMaster.CustomField24 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField25":
        //                                            objContactMaster.CustomField25 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField26":
        //                                            objContactMaster.CustomField26 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField27":
        //                                            objContactMaster.CustomField27 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField28":
        //                                            objContactMaster.CustomField28 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField29":
        //                                            objContactMaster.CustomField29 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField30":
        //                                            objContactMaster.CustomField30 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField31":
        //                                            objContactMaster.CustomField31 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField32":
        //                                            objContactMaster.CustomField32 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField33":
        //                                            objContactMaster.CustomField33 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField34":
        //                                            objContactMaster.CustomField34 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField35":
        //                                            objContactMaster.CustomField35 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField36":
        //                                            objContactMaster.CustomField36 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField37":
        //                                            objContactMaster.CustomField37 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField38":
        //                                            objContactMaster.CustomField38 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField39":
        //                                            objContactMaster.CustomField39 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField40":
        //                                            objContactMaster.CustomField40 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField41":
        //                                            objContactMaster.CustomField41 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField42":
        //                                            objContactMaster.CustomField42 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField43":
        //                                            objContactMaster.CustomField43 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField44":
        //                                            objContactMaster.CustomField44 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField45":
        //                                            objContactMaster.CustomField45 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField46":
        //                                            objContactMaster.CustomField46 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField47":
        //                                            objContactMaster.CustomField47 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField48":
        //                                            objContactMaster.CustomField48 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField49":
        //                                            objContactMaster.CustomField49 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                        case "CustomField50":
        //                                            objContactMaster.CustomField50 = contact[column.ColumnName].ToString();
        //                                            break;
        //                                    }
        //                                }


        //                            }

        //                            #endregion
        //                            objContactMaster.IsActive = true;
        //                            objContactMaster.InsertWithDefaultValues(true);
        //                            Int64 ContactId = Convert.ToInt64(objContactMaster.ContactId);
        //                            ContactIds = ContactIds + ContactId + ",";
        //                            Logger.logdata(logforRpService, "Recipient Added Successfully");

        //                        }
        //                        catch (Exception ex)
        //                        {
        //                            str.Append("<Error>Add New Contact: Problem at adding contact</Error>");
        //                            Logger.logdata(logforRpService, ex.Message);

        //                        }

        //                    }

        //                }
        //                Logger.logdata(logforRpService, "SendCampaign() at Contacts region end");

        //            }
        //            else
        //            {
        //                str.Append("<Error>No records found to send Campaign</Error>");
        //            }


        //            LogEndInfo("AddRecipient");
        //        #endregion
        //            TemplateMaster tempMaster = null;
        //            #region Template
        //            try
        //            {
        //                Logger.logdata(logforRpService, "SendCampaign() at Template region");
        //                TemplateMasters obj = TemplateMaster.SelectByField("TemplateName", TemplateName, Con);
        //                if (obj.Count > 0)
        //                {
        //                    TemplateMasterPrimaryKey template = new TemplateMasterPrimaryKey(Convert.ToInt64(obj[0].TemplateId.ToString()));
        //                    tempMaster = TemplateMaster.SelectOne(template, Con);
        //                }
        //                else
        //                {
        //                    str.Append("<Error>" + TemplateName + " Template Not found</Error>");

        //                }
        //                Logger.logdata(logforRpService, "SendCampaign() at Template region end");

        //            }
        //            catch (Exception ex)
        //            {

        //                str.Append("<Error>Template: Problem at getting mail content</Error>");
        //                Logger.logdata(logforRpService, ex.Message);
        //            }

        //            #endregion
        //            ListMasterBase listMaster = null;
        //            Int64 listid = 0;
        //            #region List
        //            try
        //            {
        //                Logger.logdata(logforRpService, "SendCampaign() at List region");
        //                if (str.ToString().IndexOf("Error") == -1)
        //                {
        //                    listMaster = new ListMasterBase(Con);
        //                    listMaster.ListName = "4VL_" + DateTime.Now;
        //                    listMaster.CreatedDate = System.DateTime.Now;
        //                    listMaster.InsertWithDefaultValues(true);
        //                    listid = Convert.ToInt64(listMaster.ListMasterID);
        //                    str.Append("<ListId>" + listid.ToString() + "</ListId>");
        //                    ContactIds = ContactIds.Substring(0, ContactIds.Length - 1);
        //                    string[] selectContact = ContactIds.Split(',');
        //                    if (listid > 0)
        //                    {
        //                        DataTable dtListContactMaster = new DataTable();
        //                        dtListContactMaster.Columns.Add(new DataColumn("ListMasterID", typeof(string)));
        //                        dtListContactMaster.Columns.Add(new DataColumn("ContactId", typeof(string)));
        //                        dtListContactMaster.Columns.Add(new DataColumn("CreatedDate", typeof(string)));
        //                        dtListContactMaster.Columns.Add(new DataColumn("ModifiedDate", typeof(string)));
        //                        StringBuilder strbAddedContacts = new StringBuilder();
        //                        //ArrayList contactsSelected = (ArrayList)Session["SelectedContacts"];
        //                        foreach (string contactID in selectContact)
        //                        {
        //                            DataRow rowListContactMaster = dtListContactMaster.NewRow();
        //                            rowListContactMaster["ListMasterID"] = listid;
        //                            rowListContactMaster["ContactId"] = contactID;
        //                            rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
        //                            rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
        //                            dtListContactMaster.Rows.Add(rowListContactMaster);
        //                        }
        //                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate" };
        //                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate" };
        //                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, Con);
        //                        str.Append("<Message>Recipients Add Successfully to Lists</Message>");
        //                    }
        //                }
        //                Logger.logdata(logforRpService, "SendCampaign() at List region end");


        //            }
        //            catch (Exception ex)
        //            {
        //                str.Append("<Error>List: Problem at ListCreation contact</Error>");
        //                Logger.logdata(logforRpService, ex.Message);
        //            }


        //            #endregion
        //            #region SendCampaign
        //            if (listMaster != null && listid > 0 && str.ToString().IndexOf("Error") == -1)
        //            {
        //                try
        //                {
        //                    Logger.logdata(logforRpService, "SendCampaign() at SendCampaign region");
        //                    CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", CampaignName, Con);
        //                    if (camp.Count > 0)
        //                    {
        //                        str.Append("<CampaignId>" + camp[0].CampaignId.ToString() + "</CampaignId>");
        //                        str.Append("<Message>Campaign Name AllReady Exist</Message>");
        //                    }
        //                    else
        //                    {
        //                        CampaignMaster objCampaignMaster = new CampaignMaster(Con);
        //                        objCampaignMaster.CampaignName = CampaignName;
        //                        objCampaignMaster.CampaignDescription = "";
        //                        objCampaignMaster.FromAddress = FromAddress;
        //                        objCampaignMaster.FromName = FromName;
        //                        objCampaignMaster.ReplytoAddress = ReplyToAddress;
        //                        objCampaignMaster.ReplaytoName = "";
        //                        objCampaignMaster.Subject = Subject;
        //                        objCampaignMaster.TrackReads = true;//"1";
        //                        objCampaignMaster.SelectCondition = listid.ToString();
        //                        objCampaignMaster.TemplateId = tempMaster.TemplateId;

        //                        objCampaignMaster.ModifiedDate = DateTime.Now;
        //                        objCampaignMaster.CreatedDate = DateTime.Now;

        //                        objCampaignMaster.HTMLContent = tempMaster.HTMLContent;
        //                        objCampaignMaster.TextContent = "";
        //                        objCampaignMaster.SuppressDomain = "";
        //                        objCampaignMaster.UnsubscribeText = "";
        //                        objCampaignMaster.UnsubscribeLinkText = "";
        //                        objCampaignMaster.SuppressSelection = "";
        //                        Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
        //                        if (campaignMasterID > 0)
        //                        {
        //                            CampaignJob objCampaignJob = new CampaignJob(Con);
        //                            objCampaignJob.CampaignMasterID = campaignMasterID;
        //                            objCampaignJob.CreatedDatetime = DateTime.Now;
        //                            objCampaignJob.ScheduledDatetime = DateTime.Now.AddMinutes(2);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
        //                            objCampaignJob.SendType = "IMMEDIATE";
        //                            objCampaignJob.Status = 1;
        //                            objCampaignJob.Insert();
        //                        }
        //                        str.Append("<TemplateID>" + tempMaster.TemplateId.ToString() + "</TemplateID>");
        //                        str.Append("<CampaignId>" + campaignMasterID.ToString() + "</CampaignId>");
        //                        str.Append("<Message>Campaign Inserted Succefully</Message>");
        //                        Logger.logdata(logforRpService, "SendCampaign() at SendCampaign region end");

        //                    }


        //                }
        //                catch (Exception ex)
        //                {
        //                    str.Append("<Error>Send Campaign :" + ex.Message + "</Error>");
        //                    Logger.logdata(logforRpService, ex.Message);
        //                }

        //            }
        //        }
        //        else
        //        {
        //            str.Append("<Error>Failed to Connect Database</Error>");
        //            Logger.logdata(logforRpService, "Please Enter Valid Inputs");
        //        }
        //            #endregion


        //    }
        //    catch (Exception ex)
        //    {
        //        str.Append("<Error>" + ex.Message + "</Error>");
        //        Logger.logError(logforRpService, ex);
        //    }
        //    str.Append("</CampaignDetails>");
        //    doc.LoadXml(str.ToString());
        //    return doc;

        //}
        public string ScheduleCampaign(string Con, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, string ListID)
        {
            TemplateMaster tempMaster = null;
            try
            {

                TemplateMasters obj = TemplateMaster.SelectByField("TemplateName", TemplateName, Con);
                if (obj.Count > 0)
                {
                    TemplateMasterPrimaryKey template = new TemplateMasterPrimaryKey(Convert.ToInt64(obj[0].TemplateId.ToString()));
                    tempMaster = TemplateMaster.SelectOne(template, Con);
                    CampaignMaster objCampaignMaster = new CampaignMaster(Con);
                    objCampaignMaster.CampaignName = CampaignName;
                    objCampaignMaster.CampaignDescription = "";
                    objCampaignMaster.FromAddress = FromAddress;
                    objCampaignMaster.FromName = FromName;
                    objCampaignMaster.ReplytoAddress = ReplyToAddress;
                    objCampaignMaster.ReplaytoName = FromName;
                    objCampaignMaster.Subject = Subject;
                    objCampaignMaster.TrackReads = true;//"1";
                    objCampaignMaster.SelectCondition = ListID;
                    objCampaignMaster.TemplateId = tempMaster.TemplateId;

                    objCampaignMaster.ModifiedDate = DateTime.Now;
                    objCampaignMaster.CreatedDate = DateTime.Now;

                    objCampaignMaster.HTMLContent = tempMaster.HTMLContent;
                    objCampaignMaster.TextContent = "";
                    objCampaignMaster.SuppressDomain = "";
                    objCampaignMaster.UnsubscribeText = "";
                    objCampaignMaster.UnsubscribeLinkText = "";
                    objCampaignMaster.SuppressSelection = "";
                    objCampaignMaster.AssignedCampaignID = 0;
                    Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                    if (campaignMasterID > 0)
                    {
                        CampaignJob objCampaignJob = new CampaignJob(Con);
                        objCampaignJob.CampaignMasterID = campaignMasterID;
                        objCampaignJob.CreatedDatetime = DateTime.Now;
                        objCampaignJob.ScheduledDatetime = DateTime.Now.AddMinutes(2);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
                        objCampaignJob.SendType = "IMMEDIATE";
                        objCampaignJob.Status = 1;
                        objCampaignJob.Insert();
                    }
                    Logger.logdata(logforRpService, "Campaign Inserted Succefully");
                    return (campaignMasterID.ToString());
                }
                else
                {
                    return ("False");
                }

            }
            catch (Exception ex)
            {
                Logger.logdata(logforRpService, ex.Message);
                return ("False");
            }


        }
Beispiel #5
0
        public string ScheduleMailingWithCampaignID(string Con, long CampaignID, string CampaignName, string Subject, string FromName, string ReplyToAddress, string FromAddress, string TemplateName, string ListID, string SuppressDomain)
        {
            TemplateMaster tempMaster = null;
            try
            {

                TemplateMasters obj = TemplateMaster.SelectByField("TemplateName", TemplateName, Con);
                if (obj.Count > 0)
                {
                    TemplateMasterPrimaryKey template = new TemplateMasterPrimaryKey(Convert.ToInt64(obj[0].TemplateId.ToString()));
                    tempMaster = TemplateMaster.SelectOne(template, Con);
                    CampaignMaster objCampaignMaster = new CampaignMaster(Con);
                    objCampaignMaster.CampaignName = CampaignName;
                    objCampaignMaster.CampaignDescription = "";
                    objCampaignMaster.FromAddress = FromAddress;
                    objCampaignMaster.FromName = FromName;
                    objCampaignMaster.ReplytoAddress = ReplyToAddress;
                    objCampaignMaster.ReplaytoName = FromName;
                    objCampaignMaster.Subject = Subject;
                    objCampaignMaster.TrackReads = true;//"1";
                    objCampaignMaster.SelectCondition = ListID;
                    objCampaignMaster.TemplateId = tempMaster.TemplateId;
                    objCampaignMaster.ModifiedDate = DateTime.Now;
                    objCampaignMaster.CreatedDate = DateTime.Now;
                    objCampaignMaster.HTMLContent = tempMaster.HTMLContent;
                    objCampaignMaster.TextContent = "";
                    objCampaignMaster.SuppressDomain = (SuppressDomain == null) ? "" : SuppressDomain;
                    objCampaignMaster.UnsubscribeText = "";
                    objCampaignMaster.UnsubscribeLinkText = "";
                    objCampaignMaster.SuppressSelection = "";
                    objCampaignMaster.AssignedCampaignID = CampaignID;
                    Int64 MailingID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                    #region Domine suppress
                    //Create a DataTable for as a parameter to sp
                    DataTable dtDomains = new DataTable();
                    //DataColumn 
                    dtDomains.Columns.Add("DomainName", typeof(string));
                    if (SuppressDomain.Trim().Length > 0)
                    {
                        if (SuppressDomain.Contains(","))
                        {
                            string[] domains = SuppressDomain.Split(',');
                            for (int i = 0; i < domains.Length; i++)
                                dtDomains.Rows.Add(domains[i]);
                        }
                        else
                            dtDomains.Rows.Add(SuppressDomain);
                    }
                    ListContactMaster objListContactMaster = new ListContactMaster(Con);
                    objListContactMaster.InsertInToDomainSuppress_Bulk((int)MailingID, ListID.ToString(), dtDomains); //CampaignMasterIDforUddate, id, ListOfContactIds.ToString(), SuppressDomain);

                    #endregion
                    if (MailingID > 0)
                    {
                        CampaignJob objCampaignJob = new CampaignJob(Con);
                        objCampaignJob.CampaignMasterID = MailingID;
                        objCampaignJob.CreatedDatetime = DateTime.Now;
                        objCampaignJob.ScheduledDatetime = DateTime.Now.AddMinutes(2);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
                        objCampaignJob.SendType = "IMMEDIATE";
                        objCampaignJob.Status = 1;
                        objCampaignJob.Insert();
                    }
                    Logger.logdata(logforRpService, "Mailing Inserted Succefully");
                    return (MailingID.ToString());
                }
                else
                {
                    return ("False");
                }

            }
            catch (Exception ex)
            {
                Logger.logdata(logforRpService, ex.Message);
                return ("False");
            }


        }
        public bool saveCampaignDetailsTab(bool Rflag)
        {
            if (txtCampaignName.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter Mailing name in Mailing Details Tab.')", true);
                Rflag = false;
            }
            else if (ddlFromAddress.SelectedItem.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter FromAddress.')", true);
                Rflag = false;
            }
            else if (txtFromName.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter FromName.')", true);
                Rflag = false;
            }
            else if (txtSubject.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Please enter subject from Mailing Details tab.')", true);
                Rflag = false;
            }
            else
            {
                if (hiddenCampaignID.Value == string.Empty)
                {
                    objCampaignMaster = new CampaignMaster(ConnectionString);
                    DataTable campMaster = CampaignMasterBase.SelectByName("CampaignName", txtCampaignName.Text.ToString(), ConnectionString);
                    if (campMaster.Rows.Count != 0)
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Mailing already Exists with this Name.')", true);
                        Rflag = false;
                    }
                    else
                    {
                        objCampaignMaster.CampaignName = txtCampaignName.Text;
                        objCampaignMaster.CampaignDescription = txtCampaignDescription.Text;
                        objCampaignMaster.FromAddress = ddlFromAddress.SelectedItem.Text;
                        objCampaignMaster.FromName = txtFromName.Text;
                        objCampaignMaster.ReplytoAddress = txtReplytoAddress.Text;
                        objCampaignMaster.ReplaytoName = txtReplaytoName.Text;
                        objCampaignMaster.Subject = txtSubject.Text;
                        objCampaignMaster.TrackReads = chkTrackReads.Checked;

                        if (RadEditor1.Content.ToString().Trim().Length != 0)
                            objCampaignMaster.htmlHasUnsubLink = chkAddress.Checked;
                        else
                            objCampaignMaster.htmlHasUnsubLink = false;
                        if (textRadEditor.Content.ToString().Trim().Length != 0)
                            objCampaignMaster.txtHasUnsubLink = chkTxtAddress.Checked;
                        else
                            objCampaignMaster.txtHasUnsubLink = false;

                        objCampaignMaster.UnsubscribeText = txtUnsubscribe.Text;
                        objCampaignMaster.UnsubscribeLinkText = DDLinktext.SelectedItem.Text;
                        if (ddlCampsNames.Text != defaultListItem)
                            objCampaignMaster.AssignedCampaignID = Convert.ToInt64(ddlCampsNames.SelectedItem.Value);
                        else
                            objCampaignMaster.AssignedCampaignID = 0;
                        lblunsubinfo.Text = txtUnsubscribe.Text;
                        lblunsublinktext.Text = DDLinktext.SelectedItem.Text;
                        DivUnsubtext.InnerHtml = lblunsubinfo.Text + " \n" + lblunsublinktext.Text;

                        objCampaignMaster.TemplateId = 0;
                        objCampaignMaster.HTMLContent = string.Empty;
                        objCampaignMaster.TextContent = string.Empty;
                        objCampaignMaster.SelectCondition = string.Empty;
                        objCampaignMaster.SuppressDomain = string.Empty;
                        objCampaignMaster.SuppressSelection = string.Empty;

                        Int64 campaignMasterID = objCampaignMaster.insertMailing(objCampaignMaster);
                        if (campaignMasterID > 0)
                        {
                            //Insert In CampaignJob Table
                            CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                            objCampaignJob.CampaignMasterID = campaignMasterID;
                            objCampaignJob.CreatedDatetime = DateTime.Now;
                            objCampaignJob.ScheduledDatetime = DateTime.Now; //Convert.ToDateTime(scheduledTime);
                            objCampaignJob.SendType = sendType;
                            objCampaignJob.Status = 5;
                            objCampaignJob.Insert();

                            //Insert in CampaignMailing Table
                            if (ddlCampsNames.Text != defaultListItem)
                            {
                                CampaignMailing objCampaignMailing = new CampaignMailing(ConnectionString);
                                objCampaignMailing.CampaignId = campaignMasterID;
                                objCampaignMailing.CampaignsID = Convert.ToInt64(ddlCampsNames.SelectedItem.Value);//Mailing Id
                                objCampaignMailing.CreatedDate = DateTime.Now;
                                objCampaignMailing.ModifiedDate = DateTime.Now;
                                objCampaignMailing.IsActive = true;
                                objCampaignMailing.Insert();
                            }
                            status = true;
                            insert = true;
                        }
                        hiddenCampaignID.Value = campaignMasterID.ToString();
                        lblCampName.Text = objCampaignMaster.CampaignName.ToString().Trim();
                        Rflag = true;
                        statusType = "Inserted";
                        //statusType = "Updated";
                        ViewState["statusType"] = "Inserted";
                        hdCampDetailsTab1.Value = "0"; //After Save CampaignDetails Iam Change the Value of Hidden Variable value to Zero.
                    }
                }
                else
                {
                    updateCampaignDetailsTab();
                    Rflag = true;
                }
            }
            return Rflag;
        }
        public XmlDocument AddMailingWithMinData(string UserID, string Password, string MailingName, string FromName, string FromAddress, string Subject, DataSet Recipients)
        {

            XmlDocument doc = new System.Xml.XmlDocument();
            StringBuilder str = new StringBuilder();
            StringBuilder unDeleverdInfo = new StringBuilder();
            bool isTargetListHavingEmailIds = false;
            List<string> emailColumns = new List<string>();
            emailColumns.Add("Email Address");
            emailColumns.Add("emailaddress");
            emailColumns.Add("email");
            emailColumns.Add("e-mail");
            emailColumns.Add("Email");
            emailColumns.Add("e-mailaddress");
            emailColumns.Add("emailaddress");
            emailColumns.Add("emailadd");
            emailColumns.Add("e-mailadd");
            emailColumns.Add("emailaddress");
            List<string> fnameColumns = new List<string>();
            fnameColumns.Add("firstname");
            fnameColumns.Add("first name");
            fnameColumns.Add("fname");
            List<string> lnameColumns = new List<string>();
            lnameColumns.Add("lastname");
            lnameColumns.Add("last name");
            lnameColumns.Add("lname");
            foreach (DataColumn clm in Recipients.Tables[0].Columns)
            {
                if (emailColumns.Contains(clm.ToString().ToLower()))
                {
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "EmailAddress";
                    isTargetListHavingEmailIds = true;
                }
                else if (fnameColumns.Contains(clm.ToString().ToLower()))
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "FirstName";
                else if (lnameColumns.Contains(clm.ToString().ToLower()))
                    Recipients.Tables[0].Columns[clm.ToString()].ColumnName = "LastName";
            }
            str.Append("<MailingInfo>");
            string ConnectionString = GetConnectionString(UserID, Password);

            string validEmailIds = string.Empty;
            string unsubEmailIds = string.Empty;
            string hardBounceEmailIds = string.Empty;
            string softBounceEmailIds = string.Empty;
            string duplicateEmailids = string.Empty;
            Hashtable contatcInfo = new Hashtable();
            if (ConnectionString.Trim().Length != 0)
            {
                LogStartInfo("AddMailingWithMinData", ConnectionString, UserID);
                Logger.logdata(logforRpService, "Input Paramiters :Mailing Name = " + MailingName + "; No.of Contacts=" + Recipients.Tables[0].Rows.Count);
                if (isTargetListHavingEmailIds)
                {
                    if (MailingName.Trim().Length != 0 && Recipients.Tables.Count > 0 && Recipients.Tables[0].Rows.Count > 0)
                    {
                        Int64 listid = 0;
                        ListMasterBase listMaster = null;
                        DataTable contacts = Recipients.Tables[0];

                        CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", MailingName, ConnectionString);
                        if (camp.Count > 0)
                        {
                            str.Append("<Message>Mailing With Name " + MailingName + " Allready Exist,Please Enter Other Name</Message>");
                            Logger.logdata(logforRpService, "Mailing With Name " + MailingName + " Allready Exist,Please Enter Other Name");
                        }
                        else
                        {
                            #region TargetList
                            if (contacts.Rows.Count > 0)
                            {
                                //string[] EmailIds = contacts.AsEnumerable().Select(row => row.Field<string>("EmailAddress")).ToArray();                        
                                unDeleverdInfo.Append("<UndeliveredList>");
                                foreach (DataRow contact in contacts.Rows)
                                {
                                    ContactMasters contemail = ContactMaster.SelectByField("EmailAddress", contact["EmailAddress"].ToString(), ConnectionString);
                                    DataTable unSubDetails = new DataTable();
                                    DataTable contactMasters = ContactMaster.GetBouceStatusByEmailIds(ConnectionString, contact["EmailAddress"].ToString());
                                    if (contemail.Count > 0)
                                    {
                                        unSubDetails = UnSubscribeDetail.GetUnSubDetailsByContactId(ConnectionString, contemail[0].ContactId.ToString(), string.Empty);
                                    }
                                    if (unSubDetails.Rows.Count > 0)
                                    {
                                        unDeleverdInfo.Append("<Undelivered>");
                                        if (unSubDetails.Rows[0]["Reason"].ToString() == "GlobalUnSub")
                                        {
                                            unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                            unDeleverdInfo.Append("<RecipientStatus>Unsubscribe</RecipientStatus>");
                                            unsubEmailIds = unsubEmailIds + contact["EmailAddress"].ToString() + ";";
                                        }
                                        else if (unSubDetails.Rows[0]["Reason"].ToString() == "bad-mailbox" || unSubDetails.Rows[0]["Reason"].ToString() == "bad-domain")
                                        {
                                            unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                            unDeleverdInfo.Append("<RecipientStatus>HardBounce</RecipientStatus>");
                                            hardBounceEmailIds = hardBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                        }
                                        unDeleverdInfo.Append("</Undelivered>");
                                    }
                                    else if (contactMasters.Rows.Count > 0 && contactMasters.Rows[0]["IsActive"].ToString() == "False" && Convert.ToInt32(contactMasters.Rows[0]["SoftBounceCount"].ToString()) >= SoftBounceCount)
                                    {
                                        unDeleverdInfo.Append("<Undelivered>");
                                        unDeleverdInfo.Append("<EMailAddress>" + contact["EmailAddress"].ToString() + "</EMailAddress>");
                                        unDeleverdInfo.Append("<RecipientStatus>SoftBounce</RecipientStatus>");
                                        unDeleverdInfo.Append("</Undelivered>");
                                        softBounceEmailIds = softBounceEmailIds + contact["EmailAddress"].ToString() + ";";
                                    }
                                    else if (contemail.Count > 0 && contemail[0].EmailAddress.Trim().Length > 0)
                                    {
                                        try
                                        {
                                            if (contemail[0].IsActive == true)
                                            {

                                                if (!contatcInfo.ContainsKey(contemail[0].ContactId))
                                                {
                                                    contatcInfo.Add(contemail[0].ContactId, "");
                                                    validEmailIds = validEmailIds + contemail[0].EmailAddress + ";";
                                                }
                                                else
                                                    duplicateEmailids = duplicateEmailids + contemail[0].EmailAddress + ";";
                                                ContactMasterPrimaryKey pk = new ContactMasterPrimaryKey(Convert.ToInt64(contemail[0].ContactId.ToString()));
                                                ContactMaster objContactMaster = ContactMaster.SelectOne(pk, ConnectionString);

                                                #region Handling Custom fields

                                                foreach (DataColumn column in contacts.Columns)
                                                {
                                                    DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, ConnectionString);
                                                    string custField = "";
                                                    if (customFieldDt.Rows.Count > 0)
                                                    {
                                                        custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
                                                    }
                                                    else
                                                        custField = column.ColumnName;

                                                    if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                                    {

                                                        switch (custField)
                                                        {
                                                            case "EmailAddress":
                                                                objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "FirstName":
                                                                objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "LastName":
                                                                objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "Address1":
                                                                objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "City":
                                                                objContactMaster.City = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "State":
                                                                objContactMaster.State = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "PostalCode":
                                                                objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "Country":
                                                                objContactMaster.Country = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "WorkPhone":
                                                                objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "HomePhone":
                                                                objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "MobilePhone":
                                                                objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField1":
                                                                objContactMaster.CustomField1 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField2":
                                                                objContactMaster.CustomField2 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField3":
                                                                objContactMaster.CustomField3 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField4":
                                                                objContactMaster.CustomField4 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField5":
                                                                objContactMaster.CustomField5 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField6":
                                                                objContactMaster.CustomField6 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField7":
                                                                objContactMaster.CustomField7 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField8":
                                                                objContactMaster.CustomField8 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField9":
                                                                objContactMaster.CustomField9 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField10":
                                                                objContactMaster.CustomField10 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField11":
                                                                objContactMaster.CustomField11 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField12":
                                                                objContactMaster.CustomField12 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField13":
                                                                objContactMaster.CustomField13 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField14":
                                                                objContactMaster.CustomField14 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField15":
                                                                objContactMaster.CustomField15 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField16":
                                                                objContactMaster.CustomField16 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField17":
                                                                objContactMaster.CustomField17 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField18":
                                                                objContactMaster.CustomField18 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField19":
                                                                objContactMaster.CustomField19 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField20":
                                                                objContactMaster.CustomField20 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField21":
                                                                objContactMaster.CustomField21 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField22":
                                                                objContactMaster.CustomField22 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField23":
                                                                objContactMaster.CustomField23 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField24":
                                                                objContactMaster.CustomField24 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField25":
                                                                objContactMaster.CustomField25 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField26":
                                                                objContactMaster.CustomField26 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField27":
                                                                objContactMaster.CustomField27 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField28":
                                                                objContactMaster.CustomField28 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField29":
                                                                objContactMaster.CustomField29 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField30":
                                                                objContactMaster.CustomField30 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField31":
                                                                objContactMaster.CustomField31 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField32":
                                                                objContactMaster.CustomField32 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField33":
                                                                objContactMaster.CustomField33 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField34":
                                                                objContactMaster.CustomField34 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField35":
                                                                objContactMaster.CustomField35 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField36":
                                                                objContactMaster.CustomField36 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField37":
                                                                objContactMaster.CustomField37 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField38":
                                                                objContactMaster.CustomField38 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField39":
                                                                objContactMaster.CustomField39 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField40":
                                                                objContactMaster.CustomField40 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField41":
                                                                objContactMaster.CustomField41 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField42":
                                                                objContactMaster.CustomField42 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField43":
                                                                objContactMaster.CustomField43 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField44":
                                                                objContactMaster.CustomField44 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField45":
                                                                objContactMaster.CustomField45 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField46":
                                                                objContactMaster.CustomField46 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField47":
                                                                objContactMaster.CustomField47 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField48":
                                                                objContactMaster.CustomField48 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField49":
                                                                objContactMaster.CustomField49 = contact[column.ColumnName].ToString();
                                                                break;
                                                            case "CustomField50":
                                                                objContactMaster.CustomField50 = contact[column.ColumnName].ToString();
                                                                break;
                                                        }
                                                    }


                                                }

                                                #endregion
                                                if (objContactMaster.Update() == true)
                                                {
                                                    //str.Append("<Message>Recipient Updated Successfully</Message>");
                                                }
                                                else
                                                {
                                                    //str.Append("<Error>Recipient  Update Failed</Error>");
                                                    Logger.logdata(logforRpService, "Recipient  Update Failed");
                                                }
                                            }

                                        }
                                        catch (Exception ex)
                                        {
                                            str.Append("<Error>Edit Contact: Problem at updating contact</Error>");
                                            Logger.logdata(logforRpService, "Update Contact :" + ex.Message);

                                        }

                                    }
                                    else if (contact["EmailAddress"] != null && contact["EmailAddress"].ToString().Trim().Length > 0)
                                    {
                                        try
                                        {
                                            ContactMaster objContactMaster = new ContactMaster(ConnectionString);
                                            objContactMaster.EmailAddress = contact["EmailAddress"].ToString();
                                            objContactMaster.EmailContentType = "Html";
                                            objContactMaster.CreatedDate = DateTime.Now;

                                            #region Handling Custom fields

                                            foreach (DataColumn column in contacts.Columns)
                                            {
                                                DataTable customFieldDt = ManageFieldsBase.SelectByField("FieldName", column.ColumnName, ConnectionString);
                                                string custField = "";
                                                if (customFieldDt.Rows.Count > 0)
                                                {
                                                    custField = customFieldDt.Rows[0]["ContactFieldName"].ToString();
                                                }
                                                else
                                                    custField = column.ColumnName;

                                                if (custField != "" && !string.IsNullOrEmpty(contact[column.ColumnName].ToString()))
                                                {
                                                    switch (custField)
                                                    {
                                                        case "EmailAddress":
                                                            objContactMaster.EmailAddress = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "FirstName":
                                                            objContactMaster.FirstName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "LastName":
                                                            objContactMaster.LastName = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Address1":
                                                            objContactMaster.Address1 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "City":
                                                            objContactMaster.City = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "State":
                                                            objContactMaster.State = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "PostalCode":
                                                            objContactMaster.PostalCode = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "Country":
                                                            objContactMaster.Country = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "WorkPhone":
                                                            objContactMaster.WorkPhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "HomePhone":
                                                            objContactMaster.HomePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "MobilePhone":
                                                            objContactMaster.MobilePhone = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField1":
                                                            objContactMaster.CustomField1 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField2":
                                                            objContactMaster.CustomField2 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField3":
                                                            objContactMaster.CustomField3 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField4":
                                                            objContactMaster.CustomField4 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField5":
                                                            objContactMaster.CustomField5 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField6":
                                                            objContactMaster.CustomField6 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField7":
                                                            objContactMaster.CustomField7 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField8":
                                                            objContactMaster.CustomField8 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField9":
                                                            objContactMaster.CustomField9 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField10":
                                                            objContactMaster.CustomField10 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField11":
                                                            objContactMaster.CustomField11 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField12":
                                                            objContactMaster.CustomField12 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField13":
                                                            objContactMaster.CustomField13 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField14":
                                                            objContactMaster.CustomField14 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField15":
                                                            objContactMaster.CustomField15 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField16":
                                                            objContactMaster.CustomField16 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField17":
                                                            objContactMaster.CustomField17 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField18":
                                                            objContactMaster.CustomField18 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField19":
                                                            objContactMaster.CustomField19 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField20":
                                                            objContactMaster.CustomField20 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField21":
                                                            objContactMaster.CustomField21 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField22":
                                                            objContactMaster.CustomField22 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField23":
                                                            objContactMaster.CustomField23 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField24":
                                                            objContactMaster.CustomField24 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField25":
                                                            objContactMaster.CustomField25 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField26":
                                                            objContactMaster.CustomField26 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField27":
                                                            objContactMaster.CustomField27 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField28":
                                                            objContactMaster.CustomField28 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField29":
                                                            objContactMaster.CustomField29 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField30":
                                                            objContactMaster.CustomField30 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField31":
                                                            objContactMaster.CustomField31 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField32":
                                                            objContactMaster.CustomField32 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField33":
                                                            objContactMaster.CustomField33 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField34":
                                                            objContactMaster.CustomField34 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField35":
                                                            objContactMaster.CustomField35 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField36":
                                                            objContactMaster.CustomField36 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField37":
                                                            objContactMaster.CustomField37 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField38":
                                                            objContactMaster.CustomField38 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField39":
                                                            objContactMaster.CustomField39 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField40":
                                                            objContactMaster.CustomField40 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField41":
                                                            objContactMaster.CustomField41 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField42":
                                                            objContactMaster.CustomField42 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField43":
                                                            objContactMaster.CustomField43 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField44":
                                                            objContactMaster.CustomField44 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField45":
                                                            objContactMaster.CustomField45 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField46":
                                                            objContactMaster.CustomField46 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField47":
                                                            objContactMaster.CustomField47 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField48":
                                                            objContactMaster.CustomField48 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField49":
                                                            objContactMaster.CustomField49 = contact[column.ColumnName].ToString();
                                                            break;
                                                        case "CustomField50":
                                                            objContactMaster.CustomField50 = contact[column.ColumnName].ToString();
                                                            break;
                                                    }
                                                }


                                            }

                                            #endregion
                                            objContactMaster.IsActive = true;
                                            objContactMaster.InsertWithDefaultValues(true);
                                            Int64 ContactId = Convert.ToInt64(objContactMaster.ContactId);
                                            // ContactIds = ContactIds + ContactId + ",";

                                            if (!contatcInfo.ContainsKey(ContactId))
                                            {
                                                contatcInfo.Add(ContactId, "");
                                                validEmailIds = validEmailIds + contact["EmailAddress"].ToString() + ";";
                                            }
                                            else
                                                duplicateEmailids = duplicateEmailids + contact["EmailAddress"].ToString() + ";";

                                        }
                                        catch (Exception ex)
                                        {
                                            str.Append("<Error>Add New Contact: Problem at adding contact</Error>");
                                            Logger.logdata(logforRpService, "Add New Contact: " + ex.Message);

                                        }

                                    }

                                }
                                unDeleverdInfo.Append("</UndeliveredList>");

                            }

                            try
                            {

                                if (str.ToString().IndexOf("<Error>") == -1 && contatcInfo.Count > 0)
                                {

                                    listMaster = new ListMasterBase(ConnectionString);
                                    listMaster.ListName = "TL_" + DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                                    listMaster.CreatedDate = System.DateTime.Now;
                                    listMaster.InsertWithDefaultValues(true);
                                    listid = Convert.ToInt64(listMaster.ListMasterID);
                                    Logger.logdata(logforRpService, "List Created,ListID = " + listid + "; ListName=" + listMaster.ListName);
                                    //ContactIds = ContactIds.Substring(0, ContactIds.Length - 1);
                                    //string[] selectContact = ContactIds.Split(',');
                                    if (listid > 0)
                                    {

                                        DataTable dtListContactMaster = new DataTable();
                                        dtListContactMaster.Columns.Add(new DataColumn("ListMasterID", typeof(string)));
                                        dtListContactMaster.Columns.Add(new DataColumn("ContactId", typeof(string)));
                                        dtListContactMaster.Columns.Add(new DataColumn("CreatedDate", typeof(string)));
                                        dtListContactMaster.Columns.Add(new DataColumn("ModifiedDate", typeof(string)));
                                        dtListContactMaster.Columns.Add(new DataColumn("IsActive", typeof(bool)));
                                        StringBuilder strbAddedContacts = new StringBuilder();

                                        foreach (DictionaryEntry item in contatcInfo)
                                        {
                                            DataRow rowListContactMaster = dtListContactMaster.NewRow();
                                            rowListContactMaster["ListMasterID"] = listid;
                                            rowListContactMaster["ContactId"] = item.Key;
                                            rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
                                            rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                                            rowListContactMaster["IsActive"] = true;
                                            dtListContactMaster.Rows.Add(rowListContactMaster);
                                        }
                                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, ConnectionString);
                                        Logger.logdata(logforRpService, "Added Given Contacts to Created List(ListId :" + listid + ")");

                                    }
                                }


                            }
                            catch (Exception ex)
                            {
                                str.Append("<Error>List: Problem at ListCreation contact</Error>");
                                Logger.logdata(logforRpService, "List: " + ex.Message);
                            }


                            #endregion

                            try
                            {
                                if (str.ToString().IndexOf("<Error>") == -1)
                                {
                                    MembershipUser objMembershipUser = Membership.GetUser(UserID);
                                    ProfileBase objProfileBase = ProfileBase.Create(UserID, true);

                                    CampaignMaster objCampaignMaster = new CampaignMaster(ConnectionString);
                                    objCampaignMaster.CampaignName = MailingName;
                                    objCampaignMaster.CampaignDescription = "";
                                    objCampaignMaster.FromAddress = FromAddress;
                                    objCampaignMaster.FromName = FromName;
                                    objCampaignMaster.ReplytoAddress = "";
                                    objCampaignMaster.ReplaytoName = "";
                                    objCampaignMaster.Subject = Subject;
                                    objCampaignMaster.TrackReads = true;//"1";
                                    objCampaignMaster.SelectCondition = listid.ToString();
                                    objCampaignMaster.TemplateId = 0;
                                    objCampaignMaster.ModifiedDate = DateTime.Now;
                                    objCampaignMaster.CreatedDate = DateTime.Now;
                                    objCampaignMaster.HTMLContent = "";
                                    objCampaignMaster.TextContent = "";
                                    objCampaignMaster.SuppressDomain = "";
                                    objCampaignMaster.UnsubscribeText = "If you no longer wish to receive these emails, simply click on the following link:";
                                    objCampaignMaster.UnsubscribeLinkText = "Unsubscribe";
                                    objCampaignMaster.SuppressSelection = "";
                                    objCampaignMaster.htmlHasUnsubLink = false;
                                    objCampaignMaster.txtHasUnsubLink = false;
                                    objCampaignMaster.AssignedCampaignID = 0;
                                    Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                                    Logger.logdata(logforRpService, "Mailing Inserted Successfully(Mailing Id:" + campaignMasterID + ")");
                                    if (campaignMasterID > 0)
                                    {
                                        CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                                        objCampaignJob.CampaignMasterID = campaignMasterID;
                                        objCampaignJob.CreatedDatetime = DateTime.Now;
                                        objCampaignJob.ScheduledDatetime = DateTime.Now;
                                        objCampaignJob.SendType = "IMMEDIATE";
                                        objCampaignJob.Status = 5;
                                        objCampaignJob.Insert();
                                    }
                                    str.Append("<Message>Mailing Inserted Succefully</Message>");
                                    str.Append("<MailingId>" + campaignMasterID.ToString() + "</MailingId>");
                                    str.Append("<MailingName>" + MailingName + "</MailingName>");
                                    str.Append("<ListID>" + listid + "</ListID>");

                                }
                                else
                                {
                                    str.Append("<Message>Mailing Sending Failed</Message>");
                                    Logger.logdata(logforRpService, "Mailing Sending Failed");

                                }
                            }
                            catch (Exception ex)
                            {
                                str.Append("<Message>Mailing Sending Failed,Problem At Scheduling The Mailing</Message>");
                                Logger.logdata(logforRpService, "Mailing Sending Failed:" + ex.Message);
                            }

                        }
                    }
                    else
                    {
                        str.Append("<Message>Please Enter Mailing Name and Ensure Mailing List File Is Not Empty</Message>");
                        Logger.logdata(logforRpService, "Empty Mailing Not Accepted and Ensure Mailing List File Is Not Empty");
                    }

                }
                else
                {
                    str.Append("<Message>No Email Address Field Found in Targeted List</Message>");
                    Logger.logdata(logforRpService, "No Email Address Field Found in Targeted List");
                }

            }
            else
            {
                str.Append("<Message>Please Enter Valid UserName and Password</Message>");
                Logger.logdata(logforRpService, "Invalid UserName or Password");
            }
            str.Append(unDeleverdInfo);
            str.Append("</MailingInfo>");
            doc.LoadXml(str.ToString());
            return doc;
        }
 public XmlDocument AddMailing(string UserID, string Password, string MailingName, string FromAdd, string FromName, string ReplyEmailAdd, string Subject, int TempId, string ListIds, DateTime LaunchDateTime)
 {
     XmlDocument doc = new System.Xml.XmlDocument();
     StringBuilder str = new StringBuilder();
     str.Append("<MailingInfo>");
     string ConnectionString = GetConnectionString(UserID, Password);
     if (ConnectionString.Trim().Length != 0)
     {
         if (IsValidEmail(FromAdd) && IsValidEmail(ReplyEmailAdd) && MailingName.Trim().Length != 0 && FromAdd.Trim().Length != 0 && FromName.Trim().Length != 0 && Subject.Trim().Length != 0 && ReplyEmailAdd.Trim().Length != 0 && TempId != 0 && ListIds.Trim().Length != 0 && LaunchDateTime != null)
         {
             CampaignMasters camp = CampaignMaster.SelectByField("CampaignName", MailingName, ConnectionString);
             if (camp.Count > 0)
             {
                 str.Append("<MailingId>" + camp[0].CampaignId.ToString() + "</MailingId>");
                 str.Append("<Message>Mailing Name Allredy Exist</Message>");
             }
             else
             {
                 TemplateMasterPrimaryKey pk = new TemplateMasterPrimaryKey(TempId);
                 TemplateMaster tempMaster = TemplateMaster.SelectOne(pk, ConnectionString);
                 if (tempMaster != null)
                 {
                     CampaignMaster objCampaignMaster = new CampaignMaster(ConnectionString);
                     objCampaignMaster.CampaignName = MailingName;
                     objCampaignMaster.CampaignDescription = "";
                     objCampaignMaster.FromAddress = FromAdd;
                     objCampaignMaster.FromName = FromName;
                     objCampaignMaster.ReplytoAddress = ReplyEmailAdd;
                     objCampaignMaster.ReplaytoName = "";
                     objCampaignMaster.Subject = Subject;
                     objCampaignMaster.TrackReads = true;//"1";
                     objCampaignMaster.SelectCondition = ListIds;
                     objCampaignMaster.TemplateId = TempId;
                     objCampaignMaster.ModifiedDate = DateTime.Now;
                     objCampaignMaster.CreatedDate = DateTime.Now;
                     objCampaignMaster.HTMLContent = tempMaster.HTMLContent;
                     objCampaignMaster.TextContent = "";
                     objCampaignMaster.SuppressDomain = "";
                     objCampaignMaster.UnsubscribeText = "If you no longer wish to receive these emails, simply click on the following link:";
                     objCampaignMaster.UnsubscribeLinkText = "Unsubscribe";
                     objCampaignMaster.SuppressSelection = "";
                     objCampaignMaster.htmlHasUnsubLink = true;
                     objCampaignMaster.txtHasUnsubLink = true;
                     objCampaignMaster.AssignedCampaignID = 0;
                     Int64 campaignMasterID = objCampaignMaster.insertCampainMaster(objCampaignMaster);
                     if (campaignMasterID > 0)
                     {
                         CampaignJob objCampaignJob = new CampaignJob(ConnectionString);
                         objCampaignJob.CampaignMasterID = campaignMasterID;
                         objCampaignJob.CreatedDatetime = DateTime.Now;
                         objCampaignJob.ScheduledDatetime = LaunchDateTime.AddMinutes(2);// DateTime.Now.AddMinutes(2);//Convert.ToDateTime(LaunchDateTime);
                         objCampaignJob.SendType = "IMMEDIATE";
                         objCampaignJob.Status = 1;
                         objCampaignJob.Insert();
                     }
                     str.Append("<MailingId>" + campaignMasterID.ToString() + "</MailingId>");
                     str.Append("<Message>Mailing Inserted Succefully</Message>");
                 }
                 else
                 {
                     str.Append("<Error>Enter Valid TemplateId</Error>");
                 }
             }
         }
         else
         {
             str.Append("<Error>Please Enter Valid Email Addresses and Ensure All The Fields are not empty</Error>");
         }
     }
     else
         str.Append("<Message>Please Enter Valid UserName and Password</Message>");
     str.Append("</MailingInfo>");
     doc.LoadXml(str.ToString());
     return doc;
 }