Open shanishkr11 opened 5 years ago
My code is following int noofemailshow = 0; if (txtnoofemail.Text.Trim() != "") noofemailshow = Convert.ToInt32(txtnoofemail.Text.Trim()); else noofemailshow = 25;
if (rememberme.Checked == true) { Response.Cookies["userid"].Value = txtEmailId.Text.Trim(); Response.Cookies["pwd"].Value = txtPassword.Text.Trim(); Response.Cookies["userid"].Expires = DateTime.Now.AddDays(15); Response.Cookies["pwd"].Expires = DateTime.Now.AddDays(15); } noofemailforfetch = noofemailshow; emailId =txtEmailId.Text.Trim(); Password = txtPassword.Text.Trim(); Pop3Client pop3Client; pop3Client = new Pop3Client(); pop3Client.Connect("pop.gmail.com", 995, true); pop3Client.Authenticate(txtEmailId.Text.Trim(), txtPassword.Text.Trim(), AuthenticationMethod.UsernameAndPassword); dt = new DataTable("Inbox"); dt.Columns.Add("counteremail", typeof(string)); dt.Columns.Add("linkforcont", typeof(string)); dt.Columns.Add("Sender", typeof(string)); dt.Columns.Add("Emails", typeof(string)); dt.Columns.Add("Subject", typeof(string)); dt.Columns.Add("Date", typeof(DateTime)); dt.Columns.Add("Reply", typeof(string)); dt.Columns.Add("Replyall", typeof(string)); dt.Columns.Add("Forward", typeof(string)); int count = pop3Client.GetMessageCount(); int counter = 0; int noofemail = 0; int noofemailtoday = 0; for (counter = count; counter >= count - noofemailshow; counter--) { Message message = pop3Client.GetMessage(counter); noofemail++; string Reply = ""; string ReplyAll = ""; string linforcontact = ""; string Forward = ""; string Subject = ""; string strimsub = ""; strimsub = getsortstring(message.Headers.Subject); Reply = string.Format("<a href='#stack2' class='btn' style='color:white' data-toggle='modal'><input type='button' class='btncontact' value='{0}' /></a>", "Reply", message.Headers.From.MailAddress); ReplyAll = string.Format("<a href = 'mailto:{1},{2}' class='btn' style='color:white'>{0}</a>", "Reply to All", message.Headers.From.MailAddress, message.Headers.Cc); Forward = string.Format("<a href = 'mailto:{1}' class='btn' style='color:white'>{0}</a>", "Forward", ""); if (message.Headers.DateSent.ToString("MM/dd/yyyy") != DateTime.Now.ToString("MM/dd/yyyy")) Subject = string.Format("<span style='color:#000000;font-weight:bold' class='checkreademail'>{0}</span><span style='float:right;color:#000000;' class='checkreademail''>{1}</span><br><span style='color:#999999'>{2}</span>", message.Headers.From.DisplayName, message.Headers.DateSent.ToShortDateString(), strimsub); else { Subject = string.Format("<span style='color:#000000;font-weight:bold' class='checkreademail''>{0}</span><span style='float:right;color:#000000;' class='checkreademail''>{1}</span><br><span style='color:#999999'>{2}</span>", message.Headers.From.DisplayName, message.Headers.DateSent.ToLongTimeString(), strimsub); noofemailtoday++; } linforcontact = checkcontact(message.Headers.From.Address); dt.Rows.Add(new object[] { counter, linforcontact, message.Headers.Sender, message.Headers.From.MailAddress, Subject, message.Headers.DateSent.ToLongDateString() + " " + message.Headers.DateSent.ToLongTimeString(), Reply, ReplyAll, Forward }); } noofmailtoday.InnerText = noofemailtoday.ToString(); EnumerableRowCollection<DataRow> rows = null; //rows = (from row in dt.AsEnumerable() // where row.Field<DateTime>("Date") > DateTime.Now.AddDays(-30) // orderby row["Date"] descending // select row); //dt = rows.AsDataView().ToTable(); gvEmail.DataSource = dt; gvEmail.DataBind(); gvEmail.Columns[0].HeaderText = "Inbox"; ViewState["Paging"] = dt;
My code is following int noofemailshow = 0; if (txtnoofemail.Text.Trim() != "") noofemailshow = Convert.ToInt32(txtnoofemail.Text.Trim()); else noofemailshow = 25;