Esempio n. 1
0
        //protected void FileList(DateTime today)
        //{
        //    System.Collections.Generic.List<string> todaysList = new System.Collections.Generic.List<string>();
        //    foreach (FileInfo fiInfo in files)
        //    {
        //        //System.IO.FileInfo flInfo = new System.IO.FileInfo(fiInfo);
        //        if (fiInfo.CreationTime.Date == today.Date) //use directly flInfo.CreationTime and flInfo.Name without create another variable
        //        {
        //            todaysList.Add(fiInfo.Name);
        //        }
        //    }
        //    LoadList(todaysList);
        //}

        protected void FileList(DateTime today)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("From");
            dt.Columns.Add("To");
            dt.Columns.Add("Subject");
            dt.Columns.Add("eFile");
            dt.Columns.Add("cDate");
            DataRow dr;

            foreach (FileInfo fiInfo in files)
            {
                //System.IO.FileInfo flInfo = new System.IO.FileInfo(fiInfo);
                if (fiInfo.CreationTime.Date == today.Date) //use directly flInfo.CreationTime and flInfo.Name without create another variable
                {
                    dr = dt.NewRow();
                    eMail em = GeteMailParticulars(fiInfo.Name);
                    dr["From"]    = em.From;
                    dr["To"]      = em.To;
                    dr["Subject"] = em.Subject;
                    dr["eFile"]   = fiInfo.Name;
                    dr["cDate"]   = RealTimeCalcultation(fiInfo.CreationTime);
                    dt.Rows.Add(dr);
                }
            }
            lblCount.Text = dt.Rows.Count + " Email(s)";
            Page.Title    = "[" + dt.Rows.Count + "] " + today.ToShortDateString();
            LoadList(dt);
        }
Esempio n. 2
0
        public eMail GeteMailParticulars(string path)
        {
            //StringBuilder email = new StringBuilder();
            string _subject, _to, _from, _cc, _Bcc, _date;
            string _path = EmailFolderPath + path;
            eMail  em    = new eMail();

            using (StreamReader sr = new StreamReader(_path))
            {
                while (!sr.EndOfStream)
                {
                    try
                    {
                        string fc = sr.ReadLine();
                        if (fc.ToString().Contains("From: "))
                        {
                            if (fc.Contains("<"))
                            {
                                _from   = Regex.Matches(fc, "<(.+)>")[0].ToString();
                                em.From = _from.Replace("From:", "").Replace("<", "").Replace(">", "");
                            }
                            else
                            {
                                string temp = fc.ToString().Replace("<", "").Replace(">", "");
                                _from   = Regex.Matches(temp, "(.+)")[0].ToString();
                                em.From = _from.Replace("From:", "").Replace("<", "").Replace(">", "");
                            }
                        }
                        if (fc.ToString().Contains("To: "))
                        {
                            if (Regex.Matches(fc, "<(.+)>").Count > 0)
                            {
                                _to = Regex.Matches(fc, "<(.+)>")[0].ToString();
                            }
                            else
                            {
                                _to = Regex.Matches(fc, "(.+)")[0].ToString();
                            }
                            em.To = _to.Replace("To:", "");
                        }
                        if (fc.ToString().Contains("Cc: "))
                        {
                            if (Regex.Matches(fc, "<(.+)>").Count > 0)
                            {
                                _cc = Regex.Matches(fc, "<(.+)>")[0].ToString();
                            }
                            else
                            {
                                _cc = Regex.Matches(fc, "(.+)")[0].ToString();
                            }
                            em.Cc = _cc.Replace("Cc:", "").Replace("<", "").Replace(">", "");
                        }
                        if (fc.ToString().Contains("Bcc: "))
                        {
                            if (Regex.Matches(fc, "<(.+)>").Count > 0)
                            {
                                _cc = Regex.Matches(fc, "<(.+)>")[0].ToString();
                            }
                            else
                            {
                                _cc = Regex.Matches(fc, "(.+)")[0].ToString();
                            }
                            em.Bcc = _cc.Replace("Bcc:", "").Replace("<", "").Replace(">", "");
                        }
                        if (fc.ToString().Contains("Date: "))
                        {
                            if (Regex.Matches(fc, "<(.+)>").Count > 0)
                            {
                                _date = Regex.Matches(fc, "<(.+)>")[0].ToString();
                            }
                            else
                            {
                                _date = Regex.Matches(fc, "(.+)")[0].ToString();
                            }
                            em.Date = _date.Replace("Date:", "");
                        }
                        if (fc.ToString().Contains("Subject: "))
                        {
                            _subject   = Regex.Matches(fc, "(.+)")[0].ToString();
                            em.Subject = _subject.Replace("Subject:", "");
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(em);
        }
Esempio n. 3
0
        public void LoadDetail(string path)
        {
            Page.Title = path;
            StringBuilder email = new StringBuilder();

            email.Append("<div><a href='Default.aspx' target='_blank' > <b>Back to list page </b></a> </div><br>");
            email.Append("<table border='1' cellspacing='0.5' cellpadding='5' />");
            email.Append("<thead class='tHeader' >");
            email.Append("<tr>");
            email.Append("<td style='width:20;'>Content </td>");
            email.Append("<td style='width:100%; text-align: center;'>Details</td>");
            email.Append("</tr>");
            email.Append("</thead>");
            email.Append("<tr class='nmColor'>");
            email.Append("<td><b>FILENAME</b> </td>");
            email.Append("<td>" + path + "</td>");
            email.Append("<tr>");

            string _path, _to, _from, _subject, _cc, _date, _urls;

            _path = EmailFolderPath + path;

            eMail em = GeteMailParticulars(path);

            _from    = em.From;
            _to      = em.To;
            _cc      = em.Cc;
            _date    = em.Date;
            _subject = em.Subject;

            email.Append("<tr class='altColor'>");
            email.Append("<td><b>FROM</b> </td>");
            email.Append("<td>" + _from + "</td>");
            email.Append("<tr>");

            email.Append("<tr class='nmColor'>");
            email.Append("<td><b>TO</b> </td>");
            email.Append("<td>" + _to + "</td>");
            email.Append("<tr>");

            email.Append("<tr class='altColor'>");
            email.Append("<td><b>CC</b> </td>");
            email.Append("<td>" + _cc + "</td>");
            email.Append("<tr>");

            email.Append("<tr class='nmColor'>");
            email.Append("<td><b>DATE</b> </td>");
            email.Append("<td>" + _date + "</td>");
            email.Append("<tr>");

            email.Append("<tr class='altColor'>");
            email.Append("<td><b>SUBJECT</b> </td>");
            email.Append("<td>" + _subject + "</td>");
            email.Append("<tr>");



            //using (StreamReader sr = new  StreamReader(_path))
            //{
            //    string fc = sr.ReadToEnd();
            //    _from = Regex.Matches(fc, "From: (.+)")[0].ToString();
            //    email.Append("<tr class='altColor'>");
            //    email.Append("<td><b>FROM</b> </td>");
            //    email.Append("<td>" + _from.Replace("From:", "") + "</td>");
            //    email.Append("<tr>");
            //    _to = Regex.Matches(fc, "To: (.+)")[0].ToString();
            //    email.Append("<tr class='nmColor'>");
            //    email.Append("<td><b>TO</b> </td>");
            //    email.Append("<td>" + _to.Replace("To:", "") + "</td>");
            //    email.Append("<tr>");
            //    _subject = Regex.Matches(fc, "Subject: (.+)")[0].ToString();
            //    email.Append("<tr class='altColor'>");
            //    email.Append("<td><b>SUBJECT</b> </td>");
            //    email.Append("<td>" + _subject.Replace("Subject:", "") + "</td>");
            //    email.Append("<tr>");


            //    //_urls = string.Empty;
            //    //foreach (Match m in Regex.Matches(fc, @"https?://([a-zA-Z\.]+)/"))
            //    //{
            //    //    _urls += m.ToString() + ' ';
            //    //}
            //    //email.Append("<tr class='altColor'>");
            //    //email.Append("<td><b>URLs</b> </td>");
            //    //email.Append("<td>" + _urls + "</td>");
            //    //email.Append("<tr>");
            //}
            //System.IO.StreamReader rd = new System.IO.StreamReader(_path);
            //int _tCount = 0;
            //StringBuilder _body = new StringBuilder();
            //while (!rd.EndOfStream)
            //{
            //    string temp = rd.ReadLine();

            //    if (_tCount > 0)
            //    {
            //        _body.AppendLine(temp);
            //    }
            //    if (temp == "Content-Transfer-Encoding: quoted-printable" && _tCount == 0)
            //    {
            //        _tCount = 1;
            //    }

            //}


            email.Append("<tr class='nmColor'>");
            email.Append("<td><b>BODY </b> </td>");
            email.Append("<td>" + GetBody(_path).Replace("\n", "<br>") + "</td>");
            email.Append("<tr>");

            email.Append("</table>");

            ltlDetails.Text = email.ToString();

            divList.Style.Add("display", "none");
            divDetails.Style.Remove("display");
        }