Exemplo n.º 1
0
        /// <summary>
        /// 转发邮件设置
        /// </summary>
        private void ForwardSet()
        {
            // 读取原邮件内容
            MailClass     mailclass  = new MailClass();
            SqlDataReader dataReader = null;

            try
            {
                dataReader = mailclass.GetMailCompleteInfoDbreader(MailID);
            }
            catch
            {
                Server.Transfer("../../Error.aspx");
            }

            if (dataReader.Read())
            {
                string tmpStr = "<br/>" + dataReader[7].ToString();
                tmpStr = tmpStr.Replace("<br/>", "\r\n>");
                this.txtSubject.Text = "Fw::" + dataReader[4].ToString();
                this.txtBody.Text    = ",你好!\n\n\n\n\n\n\n";
                this.txtBody.Text   += "=======下面是转发邮件=======\n";
                this.txtBody.Text   += "原邮件发件人姓名:" + dataReader[1].ToString() + "\n";
                this.txtBody.Text   += "原邮件发件人代号:" + dataReader[10].ToString() + "\n";
                this.txtBody.Text   += tmpStr;
            }
            dataReader.Close();



            try
            {
                dataReader = mailclass.GetMailAttInfoDbreader(MailID);
            }
            catch
            {
                Server.Transfer("../../Error.aspx");
            }
            while (dataReader.Read())
            {
                UDS.Components.MailAttachFile att = new MailAttachFile();
                att.FileAttribute  = 0;
                att.FileSize       = Int32.Parse(dataReader[1].ToString());
                att.FileName       = dataReader[0].ToString();
                att.FileAuthor     = Username;
                att.FileCatlog     = "邮件";
                att.FileVisualPath = dataReader[2].ToString();
                upattlist.Add(att);
            }
            BindAttList();


            dataReader.Close();


            mailclass = null;
        }
Exemplo n.º 2
0
        private void btnUpload_Click(object sender, System.EventArgs e)
        {
            HtmlForm FrmCompose     = (HtmlForm)this.Page.FindControl("Compose");
            Random   TempNameInt    = new Random();
            string   NewMailDirName = TempNameInt.Next(100000000).ToString();
            // 存放附件至提交人目录中,随机生成目录名
            ArrayList upattlist = (ArrayList)Session["upattlist"];
            string    FileName  = "";

            try
            {
                if (!Directory.Exists(Server.MapPath(".") + "\\AttachFiles\\tmp"))
                {
                    Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles\\tmp");
                }

                Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles\\tmp\\" + NewMailDirName + Username);
                for (int i = 0; i < FrmCompose.Controls.Count; i++)
                {
                    if (FrmCompose.Controls [i].GetType().ToString() == "System.Web.UI.HtmlControls.HtmlInputFile")
                    {
                        HtmlInputFile hif = ((HtmlInputFile)(FrmCompose.Controls[i]));
                        if (hif.PostedFile.FileName.Trim() != "")
                        {
                            FileName = System.IO.Path.GetFileName(hif.PostedFile.FileName);
                            UDS.Components.MailAttachFile att = new MailAttachFile();
                            // 初始化
                            att.FileAttribute  = 0;
                            att.FileSize       = hif.PostedFile.ContentLength;
                            att.FileName       = FileName;
                            att.FileAuthor     = Username;
                            att.FileCatlog     = "邮件";
                            att.FileVisualPath = "\\AttachFiles\\tmp\\" + NewMailDirName + Username + "\\" + FileName;
                            hif.PostedFile.SaveAs(Server.MapPath(".") + "\\AttachFiles\\tmp\\" + NewMailDirName + Username + "\\" + FileName);
                            upattlist.Add(att);
                        }
                        hif = null;
                    }
                }
                Session["upattlist"] = upattlist;
                BindAttList();
                this.SendToRealName = Request.Form["txtSendTo"].ToString();
                this.SendTo         = Request.Form["hdnTxtSendTo"].ToString();
                this.CcTo           = Request.Form["hdnTxtCcTo"].ToString();
                this.BccTo          = Request.Form["hdnTxtBccTo"].ToString();
                this.CcToRealName   = Request.Form["txtCcTo"].ToString();
                this.BccToRealName  = Request.Form["txtBccTo"].ToString();
            }
            catch (Exception ioex)
            {
                UDS.Components.Error.Log(ioex.ToString());
                Server.Transfer("../../Error.aspx");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理上传操作,附件以链接形式存放
        /// </summary>
        /// <param name="MailReceiverStr"> 用户登陆名字符串,用逗号隔开 </param>
        private ArrayList AttUpload(string MailReceiverStr)
        {
            HtmlForm FrmCompose = (HtmlForm)this.Page.FindControl("Compose");

            string[]  RecvIdAr    = System.Text.RegularExpressions.Regex.Split(MailReceiverStr, ",");
            ArrayList listattfile = new ArrayList();
            // 存放附件至发件人目录中,随机生成目录名
            Random TempNameInt    = new Random();
            string NewMailDirName = TempNameInt.Next(100000000).ToString();
            string FileName       = "";

            try
            {
                if (!Directory.Exists(Server.MapPath(".") + "\\AttachFiles\\" + Username))
                {
                    Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles\\" + Username);
                }

                Directory.CreateDirectory(Server.MapPath(".") + "\\AttachFiles\\" + Username + "\\" + NewMailDirName);
                for (int i = 0; i < FrmCompose.Controls.Count; i++)
                {
                    if (FrmCompose.Controls [i].GetType().ToString() == "System.Web.UI.HtmlControls.HtmlInputFile")
                    {
                        HtmlInputFile hif = ((HtmlInputFile)(FrmCompose.Controls[i]));
                        if (hif.PostedFile.FileName.Trim() != "")
                        {
                            FileName = System.IO.Path.GetFileName(hif.PostedFile.FileName);
                            UDS.Components.MailAttachFile att = new MailAttachFile();
                            // 初始化
                            att.FileAttribute  = 0;
                            att.FileSize       = hif.PostedFile.ContentLength;
                            att.FileName       = FileName;
                            att.FileAuthor     = Username;
                            att.FileCatlog     = "邮件";
                            att.FileVisualPath = "\\AttachFiles\\" + Username + "\\" + NewMailDirName + "\\" + FileName;
                            hif.PostedFile.SaveAs(Server.MapPath(".") + "\\AttachFiles\\" + Username + "\\" + NewMailDirName + "\\" + FileName);
                            listattfile.Add(att);
                        }
                        hif = null;
                    }
                }
            }
            catch (Exception ioex)
            {
                UDS.Components.Error.Log(ioex.ToString());
                Server.Transfer("../../Error.aspx");
            }


            return(listattfile);
        }