コード例 #1
0
    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();
    }
コード例 #2
0
    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();
    }
コード例 #3
0
    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");
    }
コード例 #4
0
    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");
    }
コード例 #5
0
    private void Download(Guid guid)
    {
        ML_AttachFileBLL bll = new ML_AttachFileBLL(guid);

        if (bll.Model == null)
        {
            Response.End();
        }

        Response.Clear();
        Response.Buffer = true;

        #region 确定ContentType
        if (bll.Model.Extname == "")
        {
            FileInfo f = new FileInfo(bll.Model.Visualpath);
            bll.Model.Extname = f.Extension;
            bll.Model.Name    = f.Name.Substring(0, f.Name.LastIndexOf("."));
        }
        switch (bll.Model.Extname.ToLower())
        {
        case "jpg":
        case "jpeg":
        case "jpe":
            Response.ContentType = "image/jpeg";
            break;

        case "gif":
            Response.ContentType = "image/gif";
            break;

        case "bmp":
            Response.ContentType = "image/bmp";
            break;

        case "png":
            Response.ContentType = "image/png";
            break;

        case "tiff":
        case "tif":
            Response.ContentType = "image/tiff";
            break;

        case "doc":
        case "docx":
            Response.ContentType = "application/ms-word";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
            Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
            break;

        case "xls":
        case "xlsx":
            Response.ContentType = "application/ms-excel";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
            Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
            break;

        case "ppt":
        case "pptx":
            Response.ContentType = "application/ms-powerpoint";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
            Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
            break;

        case "pdf":
            Response.ContentType = "application/pdf";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
            Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
            break;

        case "zip":
            Response.ContentType = "application/zip";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
            Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
            break;

        case "rar":
            Response.ContentType = "application/rar";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
            Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
            break;

        case "txt":
            Response.ContentType = "text/plain";
            break;

        case "htm":
        case "html":
            Response.ContentType = "text/html";
            break;

        default:
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
            Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
            break;
        }
        #endregion

        if (string.IsNullOrEmpty(bll.Model.Visualpath))
        {
            byte[] data = bll.GetData();
            if (data != null)
            {
                Response.OutputStream.Write(data, 0, data.Length);
            }
        }
        else
        {
            string destFileName = "";  //变量接收附件的路径
            if (bll.Model.Visualpath.StartsWith("~"))
            {
                destFileName = Server.MapPath(bll.Model.Visualpath);
            }
            else
            {
                destFileName = bll.Model.Visualpath;
            }

            //根据路径打开或另保存附件
            if (File.Exists(destFileName))
            {
                Response.WriteFile(destFileName);
                Response.Flush();
                Response.End();
            }
            else
            {
                Response.Write("<script langauge=javascript>alert('文件不存在!" + destFileName + "');</script>");
                Response.Write("<script>window.close();</script>");
            }
        }
    }
コード例 #6
0
    private void Download(Guid guid)
    {
        ML_AttachFileBLL bll = new ML_AttachFileBLL(guid);
        if (bll.Model == null) Response.End();

        Response.Clear();
        Response.Buffer = true;

        #region 确定ContentType
        if (bll.Model.Extname == "")
        {
            FileInfo f = new FileInfo(bll.Model.Visualpath);
            bll.Model.Extname = f.Extension;
            bll.Model.Name = f.Name.Substring(0, f.Name.LastIndexOf("."));
        }
        switch (bll.Model.Extname.ToLower())
        {
            case "jpg":
            case "jpeg":
            case "jpe":
                Response.ContentType = "image/jpeg";
                break;
            case "gif":
                Response.ContentType = "image/gif";
                break;
            case "bmp":
                Response.ContentType = "image/bmp";
                break;
            case "png":
                Response.ContentType = "image/png";
                break;
            case "tiff":
            case "tif":
                Response.ContentType = "image/tiff";
                break;
            case "doc":
            case "docx":
                Response.ContentType = "application/ms-word";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
                Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
                break;
            case "xls":
            case "xlsx":
                Response.ContentType = "application/ms-excel";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
                Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
                break;
            case "ppt":
            case "pptx":
                Response.ContentType = "application/ms-powerpoint";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
                Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
                break;
            case "pdf":
                Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
                Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
                break;
            case "zip":
                Response.ContentType = "application/zip";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
                Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
                break;
            case "rar":
                Response.ContentType = "application/rar";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
                Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
                break;
            case "txt":
                Response.ContentType = "text/plain";
                break;
            case "htm":
            case "html":
                Response.ContentType = "text/html";
                break;
            default:
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(bll.Model.Name));
                Response.AppendHeader("Content-Length", bll.Model.Size.ToString());
                break;
        }
        #endregion

        if (string.IsNullOrEmpty(bll.Model.Visualpath))
        {
            byte[] data = bll.GetData();
            if (data != null) Response.OutputStream.Write(data, 0, data.Length);
        }
        else
        {
            string destFileName = "";  //变量接收附件的路径
            if (bll.Model.Visualpath.StartsWith("~"))
                destFileName = Server.MapPath(bll.Model.Visualpath);
            else
                destFileName = bll.Model.Visualpath;

            //根据路径打开或另保存附件
            if (File.Exists(destFileName))
            {
                Response.WriteFile(destFileName);
                Response.Flush();
                Response.End();
            }
            else
            {
                Response.Write("<script langauge=javascript>alert('文件不存在!" + destFileName + "');</script>");
                Response.Write("<script>window.close();</script>");
            }
        }
    }