//select *,(select COUNT(IsMailSent) from dbo.EC_CampaignQueue where FK_CampaignID =65 and IsMailSent = 1) as MailSent,(select count(isBounced) from dbo.EC_CampaignQueue where FK_CampaignID =65 and isBounced = 1) as softbounce, (select count(IsHardBounce) from dbo.EC_CampaignQueue where FK_CampaignID =65 and IsHardBounce = 1) as hardbounce, (select COUNT(IsRead) from dbo.EC_CampaignQueue where FK_CampaignID =65 and IsRead = 1) as IsRead, (select COUNT(ReadCount) from dbo.EC_CampaignQueue where FK_CampaignID =65 and ReadCount = 1) as ReadCount, (select sum(ReadCount) from dbo.EC_CampaignQueue where FK_CampaignID =65) as TotalReadCount,(select COUNT(PK_CampaignQueueID) from dbo.EC_CampaignQueue where FK_CampaignID =65) as Recipients from dbo.EC_Campaign where CampaignStatus = 1 and PK_CampaignID = 65
        private void Chilkitmail()
        {
            Chilkat.MailMan mailman = new Chilkat.MailMan();
            mailman.UnlockComponent("MailUnlockCode");
            mailman.MailHost       = "pop.gmail.com";
            mailman.MailPort       = 995;
            mailman.PopUsername    = System.Configuration.ConfigurationSettings.AppSettings["AryvartAdminEmailID"].ToString();
            mailman.PopPassword    = System.Configuration.ConfigurationSettings.AppSettings["AryvartAdminEmailPassword"].ToString();
            mailman.ConnectTimeout = 200000;
            mailman.ReadTimeout    = 200000;
            Chilkat.Bounce bounce  = new Chilkat.Bounce();
            bool           success = bounce.UnlockComponent("MailUnlockCode");

            if (!success)
            {
                //TextBox1.Text = bounce.LastErrorText;
                return;
            }

            Chilkat.EmailBundle bundle;
            //object bndlmail;
            bundle = mailman.CopyMail();
            //int numBodyLines = 1;
            //bundle = mailman.GetAllHeaders(numBodyLines);

            if (bundle != null)
            {
                // Loop over each email...
                Chilkat.Email email;
                int           i;
                bool          success1;
                for (i = 0; i < bundle.MessageCount; i++)
                {
                    email = bundle.GetEmail(i);
                    string gmailuid = email.Uidl;
                    string content  = "";
                    success1 = bounce.ExamineEmail(email);
                    string bouncecolumn = "";

                    //if (!success1)
                    //    listBox1.Items.Add("Failed to classify email");
                    if (bounce.BounceType == 1)
                    {
                        // Hard bounce, log the email address
                        content      = pop3recievecontent(gmailuid);
                        bouncecolumn = "IsHardBounce";
                    }
                    else if (bounce.BounceType == 2)
                    {
                        // Soft bounce, log the email address
                        content      = pop3recievecontent(gmailuid);
                        bouncecolumn = "isBounced";
                    }
                    else if (bounce.BounceType == 3)
                    {
                        // General bounce, no email address available.
                        content      = pop3recievecontent(gmailuid);
                        bouncecolumn = "isBounced";
                    }
                    email = null;
                    if (content != "")
                    {
                        if (content.Contains("Disposition-Notification-To: <"))
                        {
                            string ll           = "Disposition-Notification-To: <";
                            int    posA         = content.IndexOf("Disposition-Notification-To: <");
                            int    posB         = content.LastIndexOf(">");
                            int    adjustedPosA = posA + ll.Length;
                            string uu           = content.Substring(adjustedPosA, posB - adjustedPosA);
                            string isexist      = objBL_Common.IsValidUser("MailFailedContent", "EC_CampaignQueue", "PK_CampaignQueueID =" + Convert.ToInt32(uu) + "");

                            SqlParameter param = new SqlParameter();
                            param.ParameterName = "@UserName";
                            param.Value         = content;

                            if (isexist == "")
                            {
                                objBL_Common.AccessUpdatecampue("EC_CampaignQueue", "" + bouncecolumn + "= 'true', MailFailedContent = @UserName ", "PK_CampaignQueueID =" + Convert.ToInt32(uu) + "", content);
                            }
                        }
                    }
                }
                bundle = null;
            }
            mailman = null;
        }
Пример #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                HttpCookie myCookie   = new HttpCookie("myCookie");
                bool       IsRemember = chkRememberme.Checked;
                lstUserDetails = new List <UserDetails>();
                lstUserDetails = objBL_UserLoginDetails.SelectUserDetailsforLogin(txtUsername.Value.ToString(), txtpassword.Value.ToString());

                if (lstUserDetails.Count > 0)
                {
                    if (lstUserDetails[0].AccountActivated == true)
                    {
                        if (IsRemember)
                        {
                            myCookie.Values.Add("username", txtUsername.Value);
                            myCookie.Values.Add("password", objCryptographicHashCode.EncryptPlainTextToCipherText(txtpassword.Value));
                            myCookie.Expires = DateTime.Now.AddDays(15);
                            Response.Cookies.Add(myCookie);
                        }
                        else
                        {
                            myCookie.Values.Add("username", string.Empty);
                            myCookie.Values.Add("password", string.Empty);
                            myCookie.Expires = DateTime.Now.AddMinutes(5);
                            Response.Cookies.Add(myCookie);
                        }

                        Session["UserID"]    = lstUserDetails[0].PK_UserID;
                        Session["Usertype"]  = lstUserDetails[0].UserType;
                        Session["CompanyID"] = lstUserDetails[0].FK_CompanyID;

                        if (lstUserDetails[0].FirstName == "" && lstUserDetails[0].LastName == "")
                        {
                            Session["UserName"] = lstUserDetails[0].UserName;
                        }
                        else
                        {
                            Session["UserName"] = lstUserDetails[0].FirstName + " " + lstUserDetails[0].LastName;
                        }

                        if (Session["CompanyID"].ToString() != "")
                        {
                            Session["CompanyName"] = objBL_Common.IsValidUser("Company_Name", "EC_Company", "PK_CompanyID =" + Convert.ToInt32(Session["CompanyID"].ToString()) + "");
                        }
                        else
                        {
                            Session["CompanyName"] = "-";
                        }

                        if (Convert.ToInt64(Session["Usertype"].ToString()) == 10)
                        {
                            Response.Redirect("UserPlanTypeDetails.aspx", false);
                            return;
                        }

                        if (lstUserDetails[0].FK_RoleID != null)
                        {
                            Session["RoleID"] = lstUserDetails[0].FK_RoleID;
                        }

                        if (lstUserDetails[0].UserType == 1)
                        {
                            if (lstUserDetails[0].FK_RoleID == null)
                            {
                                objRole                = new Role();
                                objRole.RoleName       = "Admin";
                                objRole.CampaignCreate = true;
                                objRole.FK_CompanyID   = Convert.ToInt32(Session["CompanyID"].ToString());
                                objRole.MailSend       = true;
                                objRole.CreateUser     = true;
                                objRole.CampaignDelete = true;
                                objRole.ViewingReports = true;
                                objRole.TemplateView   = true;
                                objRole.ListExports    = true;
                                objRole.CreatedOn      = DateTime.Now;
                                objRole.CreatedBy      = Convert.ToInt32(Session["UserID"].ToString());
                                string pkcqid = objBL_Role.AccessInsertRole(objRole);

                                if (pkcqid != "")
                                {
                                    Session["RoleID"] = Convert.ToInt32(pkcqid);
                                    objBL_Common      = new BL_Common();
                                    objBL_Common.AccessUpdateAllCampaign("EC_UserLogin", "FK_RoleID = '" + Convert.ToInt32(pkcqid) + "'", "PK_UserID =" + Convert.ToInt32(Session["UserID"].ToString()) + "");
                                    objBL_Common = null;
                                }
                            }
                        }
                        objBL_UserPlan = new BL_UserPlan();
                        lstUserPlan    = new List <UserPlan>();
                        lstUserPlan    = objBL_UserPlan.GetUserPlanBasedonCompanyID(Convert.ToInt32(Session["CompanyID"].ToString()));

                        if (lstUserPlan.Count <= 0)
                        {
                            InsertUserPlan(Convert.ToInt32(Session["UserID"].ToString()));
                            Response.Redirect("Dashboard.aspx", false);
                        }
                        else
                        {
                            Response.Redirect("Dashboard.aspx", false);
                            DataTable dtplantype = new DataTable();
                            objBL_Common = new BL_Common();
                            dtplantype   = objBL_Common.plantypedetails("*", "EC_PlanType", "PK_PlanID = " + Convert.ToInt32(lstUserPlan[0].FK_PlanID.ToString()) + " and IsActive = 1 order by plandate desc");

                            string[] UPtype = new string[3];
                            UPtype[0] = Convert.ToString(dtplantype.Rows[0]["IsSingleUser"]);
                            UPtype[1] = Convert.ToString(dtplantype.Rows[0]["NOC"]);
                            UPtype[2] = Convert.ToString(dtplantype.Rows[0]["AllowedMails"]);
                            Session["lstUserPlanType"] = UPtype;
                        }

                        if (lstUserDetails[0].Email_id != null)
                        {
                            Session["AdminEmilid"] = lstUserDetails[0].Email_id;
                        }

                        if (lstUserDetails[0].FK_RoleID != 0)
                        {
                            roledetails();
                        }
                    }
                    else
                    {
                        lblerrormsg.Text = "<span style='color:#c85305;font-size:11.5px;'>You have to activate your account from mail sent. Then only you can access your account.</span>";
                    }
                }
                else
                {
                    lblerrormsg.Text = "<span style='color:#c85305;font-size:11.5px;'>That account doesn't exist. Enter a different account detail or </span> <a href='FreeAccountSignUp.aspx' style='font-size:11.5px; color: #00acec;'>get a new account</a>";
                }
            }
            catch (Exception ex)
            {
                New_EmailCampaign.App_Code.GlobalFunction.StoreLog("UserLogin.aspx:btnSubmit_Click() - " + ex.Message);
            }
        }