public void ForwardSet(int MailID) { ML_MailBLL mailbll = new ML_MailBLL(MailID); string tmpStr = "<br/>" + mailbll.Model.Content.ToString(); tmpStr = tmpStr.Replace("<br/>", "\r\n"); this.txtSubject.Text = "Fw:" + mailbll.Model.Subject.ToString(); this.ckedit_content.Text = "你好!\n\n\n"; this.ckedit_content.Text += "=======下面是转发邮件=======\n"; this.ckedit_content.Text += "原邮件发件人姓名:" + mailbll.Model.Sender.ToString() + "\n"; this.ckedit_content.Text += "原邮件发送时间:" + mailbll.Model.SendTime.ToString() + "\n"; this.ckedit_content.Text += "原邮件收件人姓名:" + mailbll.Model.ReceiverStr.ToString() + "\n"; this.ckedit_content.Text += tmpStr; //设置附件信息 ML_AttachFileBLL attachfiledal = new ML_AttachFileBLL(); IList <ML_AttachFile> fileList = mailbll.GetAttachFiles(); if (fileList.Count != 0) { for (int i = 0; i < fileList.Count; i++) { ML_AttachFile att = new ML_AttachFile(); att.Size = fileList[i].Size; att.Name = fileList[i].Name; att.Uploaduser = fileList[i].Uploaduser; att.Extname = fileList[i].Extname; att.GUID = fileList[i].GUID; upattlist.Add(att); } } BindAttList(); }
protected void btnSendMail_Click(object sender, EventArgs e) { ML_Mail mailbody = new ML_Mail(); mailbody = ProcessFormPost(); ArrayList mails_id = ML_MailBLL.MailSend(mailbody); // 返回已经发送的邮件ID列表(包括抄送和密抄) List <int> receiverList = new List <int>(); ArrayList upattlist = (ArrayList)Session["upattlist"]; #region 将附件文件读取到字节组中 ArrayList upattbuff = new ArrayList(upattlist.Count); for (int i = 0; i < upattlist.Count; i++) { byte[] buff = null; ML_AttachFile att = (ML_AttachFile)upattlist[i]; string path = att.Visualpath; if (path == "") { //转发的附件 buff = new ML_AttachFileBLL(att.GUID).GetData(); } else { if (path.StartsWith("~")) { path = Server.MapPath(path); } FileStream stream = new FileStream(path, FileMode.Open); buff = new byte[stream.Length]; stream.Read(buff, 0, buff.Length); stream.Close(); att.Visualpath = ""; File.Delete(path); } upattbuff.Add(buff); } if (ViewState["SavePath"] != null) { string path = (string)ViewState["SavePath"]; path = path.Substring(0, path.LastIndexOf("/")); Directory.Delete(path, true); ViewState["SavePath"] = null; } #endregion ML_AttachFileBLL bll = new ML_AttachFileBLL(); for (int i = 0; i < upattlist.Count; i++) { ML_AttachFile att = (ML_AttachFile)upattlist[i]; foreach (int mailID in mails_id) { ML_AttachFileBLL attbll = new ML_AttachFileBLL(); attbll.Model = att; attbll.Model.Mailid = mailID; attbll.Add((byte[])upattbuff[i]); } } if (this.cbRemind.Checked == true) { receiverList = ProcessSM(); } Response.Redirect("index.aspx"); }
protected void btnUpload_Click(object sender, EventArgs e) { string SavePath = ConfigHelper.GetConfigString("AttachmentPath"); if (string.IsNullOrEmpty(SavePath)) { SavePath = "~/Attachment/"; } if (!SavePath.EndsWith("/") && !SavePath.EndsWith("\\")) { SavePath += "/"; } SavePath += "Mail/" + DateTime.Now.ToString("yyyyMMdd") + "/" + (string)Session["UserName"] + "/" + DateTime.Now.ToString("HHmmss"); if (SavePath.StartsWith("~")) { if (!Directory.Exists(Server.MapPath(SavePath))) { Directory.CreateDirectory(Server.MapPath(SavePath)); } } else { if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } } ViewState["SavePath"] = SavePath; ArrayList upattlist = (ArrayList)Session["upattlist"]; int size = 0; HtmlInputFile[] hif = { hif1, hif2, hif3, hif4 }; for (int i = 0; i < 4; i++) { string filename = hif[i].PostedFile.FileName.Trim(); if (filename != "") { filename = filename.Substring(filename.LastIndexOf("\\") + 1); ML_AttachFile att = new ML_AttachFile(); // 初始化 att.Name = filename; att.Size = hif[i].PostedFile.ContentLength; att.Uploaduser = (string)Session["UserName"]; att.Extname = filename.Substring(filename.LastIndexOf(".") + 1); att.Visualpath = SavePath + "/" + filename; if (SavePath.StartsWith("~")) { hif[i].PostedFile.SaveAs(Server.MapPath(SavePath) + "/" + filename); } else { hif[i].PostedFile.SaveAs(SavePath + "/" + filename); } size += att.Size; upattlist.Add(att); } } Session["upattlist"] = upattlist; if ((size / 1024) == 0) { size = 1; } else { size = size / 1024; } ViewState["UploadSize"] = size; BindAttList(); this.SendToRealName = Request.Form["txtSendTo"].ToString(); this.CcToRealName = Request.Form["txtCcTo"].ToString(); this.BccToRealName = Request.Form["txtBccTo"].ToString(); this.SendTo = Request.Form["hdnTxtSendTo"].ToString(); this.CcTo = Request.Form["hdnTxtCcTo"].ToString(); this.BccTo = Request.Form["hdnTxtBccTo"].ToString(); }