private void dgvEmailInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { strFrom = strSubject = strBody = strDate = strAttachment = string.Empty; strFrom = dgvEmailInfo.Rows[e.RowIndex].Cells[0].Value.ToString(); strSubject = dgvEmailInfo.Rows[e.RowIndex].Cells[1].Value.ToString(); strBody = dgvEmailInfo.Rows[e.RowIndex].Cells[2].Value.ToString(); strDate = dgvEmailInfo.Rows[e.RowIndex].Cells[4].Value.ToString(); mailMessage = popMail.Messages[e.RowIndex + 1]; atts = mailMessage.Attachments; for (int k = 0; k < atts.Count; k++) { att = atts[k]; if (strAttachment == string.Empty) { strAttachment = ReplaceName(att.Name); } else { strAttachment += "," + ReplaceName(att.Name); } } frmEmailInfo frmemailinfo = new frmEmailInfo(); frmemailinfo.ShowDialog(); }
private void dgvEmailInfo_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == 3) { mailMessage = popMail.Messages[e.RowIndex + 1]; atts = mailMessage.Attachments; for (int k = 0; k < atts.Count; k++) { att = atts[k]; string attname = att.Name; Directory.CreateDirectory("AttachFiles\\" + user); string mailPath = "AttachFiles\\" + user + "\\" + ReplaceName(att.Name); att.SaveToFile(mailPath); MessageBox.Show("下载成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { } }