//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; }