public void RetrieveEmail(DataTable locallist) { int downloadcount = locallist.Rows.Count; if (downloadcount > Session.MaxEmailCount) return; for (int i = mailList.Count - 1; i >= 0; i--) { bool found = false; string str = mailList[i]; foreach (DataRow row in locallist.Rows) { if (row["UIDL"].Equals(str)) { found = true; break; } } if (found == false) { downloadcount++; if (downloadcount > Session.MaxEmailCount) break; // save email data to file string filepath = Utility.GetInboxBoxPath(); FileStream fs = null; StreamWriter writer = null; try { fs = new FileStream(filepath + str, FileMode.Create, FileAccess.Write, FileShare.Read); writer = new StreamWriter(fs); // pop3 uidl index starts from 1 not 0 DownloadEmail(i + 1, writer); writer.Flush(); } catch (System.Exception) { } finally { writer.Close(); fs.Close(); } // parse email EML eml = new EML(); if (eml.ParseEML(filepath + str) == true) SaveEmailInfo(str, eml.From, eml.TimeStampRecv, eml.Subject, eml.Size); eml.Close(); } } }
private void LoadSentboxDB() { datatableSentbox = new DataTable(); // search through sent folder string filepath = Utility.GetSentBoxPath(); string[] sentFileList = Directory.GetFiles(filepath, "*.eml"); if (sentFileList.Length == 0) return; DataColumn workCol = datatableSentbox.Columns.Add("GUID", typeof(string)); workCol.AllowDBNull = false; workCol.Unique = true; datatableSentbox.Columns.Add("To", typeof(string)); datatableSentbox.Columns.Add("Date", typeof(string)); datatableSentbox.Columns.Add("Subject", typeof(string)); datatableSentbox.Columns.Add("Size", typeof(int)); foreach (string file in sentFileList) { // load eml file EML eml = new EML(); if (eml.ParseEML(file) == true) { DataRow row = datatableSentbox.NewRow(); FileInfo fileinfo = new FileInfo(file); row["GUID"] = fileinfo.Name; row["To"] = eml.To; row["Date"] = eml.TimeStampSent; row["Subject"] = eml.Subject; row["Size"] = eml.Size; datatableSentbox.Rows.Add(row); } eml.Close(); } }
private void EditMail_Load(object sender, EventArgs e) { if (filename == "") return; // load eml from parameter eml = new EML(); if (eml.ParseEML(filename) == false) { eml.Close(); return; } textBoxReceive.Text = eml.To; textBoxCC.Text = eml.CC; textBoxBCC.Text = eml.BCC; textBoxTitle.Text = eml.Subject; DateTime recvtime = DateTime.Parse(eml.TimeStampRecv); DateTime senttime = DateTime.Parse(eml.TimeStampSent); if (eml.HTMLBody != "") { richTextBoxContent.Text = eml.HTMLBody; } else { richTextBoxContent.Text = eml.TextBody; } // do not load attachment, will be added in the next version eml.Close(); }
private void ViewMail_Load(object sender, EventArgs e) { // load email content from file, file name: uidl if (filename == "") { return; } eml = new EML(); if (eml.ParseEML(filename) == false) { eml.Close(); return; } textBoxFrom.Text = eml.From; textBoxCC.Text = eml.CC; textBoxBCC.Text = eml.BCC; textBoxTitle.Text = eml.Subject; DateTime recvtime = DateTime.Parse(eml.TimeStampRecv); DateTime senttime = DateTime.Parse(eml.TimeStampSent); if(recvtime > senttime) textBoxTime.Text = eml.TimeStampRecv; else textBoxTime.Text = eml.TimeStampSent; if (eml.HTMLBody != "") { webBrowserContent.DocumentText = eml.HTMLBody; } else { webBrowserContent.DocumentText = eml.TextBody; } if (eml.AttachCount == 0) listBoxAttachment.Enabled = false; else listBoxAttachment.Enabled = true; // load attachment for (int i = 0; i < eml.AttachCount; i++) { listBoxAttachment.Items.Add(eml.GetAttachmentName(i)); } eml.Close(); }