Exemplo n.º 1
0
        void SaveMail(string vpaths)
        {
            M_Plat_Mail mailMod = new M_Plat_Mail();

            mailMod.MailType = 1;
            mailMod.MailDate = DateTime.Now;
            mailMod.Title    = TxtTitle.Text;
            mailMod.Sender   = Emails_D.SelectedItem.Text;
            mailMod.Receiver = Receiver_T.Text;
            mailMod.UserID   = buser.GetLogin().UserID;
            mailMod.Attach   = vpaths;
            mailMod.CDate    = DateTime.Now;
            mailMod.Content  = EditorContent.Text;
            mailMod.Status   = 1;
            mailBll.Insert(mailMod);
        }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Reply > 0)
         {
             M_Plat_Mail model = mailBll.SelReturnModel(Reply);
             Receiver_T.Text = model.Sender;
             TxtTitle.Text   = "回复:" + model.Title;
         }
         else if (!string.IsNullOrEmpty(REmail))
         {
             Receiver_T.Text = REmail;
         }
         MyBind();
     }
 }
Exemplo n.º 3
0
        void MyBind()
        {
            M_Plat_Mail mailMod = mailBll.SelReturnModel(MainID);

            LblSender.Text   = "<a href='MailWrite.aspx?remail=" + mailMod.Sender + "'>" + mailMod.Sender + "</a>";
            LblIncept.Text   = "<a href='MailWrite.aspx?remail=" + mailMod.Receiver + "'>" + mailMod.Receiver + "</a>";
            LblTitle.Text    = mailMod.Title;
            txt_Content.Text = mailMod.Content;
            B_User buser = new B_User();

            LblSendTime.Text = mailMod.CDate.ToString();
            Attach_Hid.Value = mailMod.Attach;
            //string vpath = "";
            //foreach (string path in mailMod.Attach.Split('|'))
            //{
            //    if (string.IsNullOrEmpty(path)) continue;
            //    vpath += function.PToV(path) + "|";
            //}
            //Attach_Hid.Value = vpath.Trim('|');
        }
        private void DownMailFunc(M_UserInfo mu, System.Web.SessionState.HttpSessionState session)
        {
            string ppath = function.VToP(SiteConfig.SiteOption.UploadDir + "\\" + mu.UserName + mu.UserID + @"\EMail\");

            SafeSC.CreateDir(ppath);
            DataTable    mailDT  = mailBll.SelMailIDByUid(mu.UserID);//避免重复下载邮件
            DataTable    dt      = configBll.SelByUid(mu.UserID);
            DownMailProg progMod = new DownMailProg();
            //-----------------
            FactoryPop3 popFactory = new FactoryPop3();
            //Pop3 pop= popFactory.CreatePop3();
            //OpenPopPop3 pop = new OpenPopPop3();
            OpenPopPop3 pop = new OpenPopPop3();

            pop.Pop3Port = 110;
            //附件的物理存储路径
            foreach (DataRow dr in dt.Rows)
            {
                pop.Pop3Address   = dr["POP"].ToString();//pop.exmail.qq.com(QQ企业邮箱),pop3.163.com,pop.exmail.qq.com,pop.qq.com
                pop.EmailAddress  = dr["ACount"].ToString();
                pop.EmailPassword = dr["Passwd"].ToString();
                try { if (!pop.Authenticate())
                      {
                          continue;
                      }
                }
                catch (Exception ex) { ZLLog.L("邮件接收异常,邮箱[" + pop.EmailAddress + "],原因:" + ex.Message); continue; }
                int count = pop.GetMailCount();
                progMod.email = pop.EmailAddress;
                progMod.total = count;
                progMod.index = 1;
                for (int i = count, index = 1; i >= 1; i--, index++)//从最后往前加,先更新日期最近的
                {
                    Session["Mail_DownProg"] = JsonConvert.SerializeObject(progMod);
                    try
                    {
                        progMod.index = index;
                        string mailid = pop.GetMailUID(i);
                        mailDT.DefaultView.RowFilter = "MailID='" + mailid + "'";
                        if (mailDT.DefaultView.ToTable().Rows.Count > 0)
                        {
                            continue;                                             //已存在
                        }
                        DateTime sendtime = pop.GetMailDate(i);
                        int      days     = DataConverter.CLng(dr["Days"].ToString()) == 0 ? 30 : DataConverter.CLng(dr["Days"].ToString());
                        //大于指定天数的邮件则不下载
                        if ((DateTime.Now - sendtime).TotalDays > days)
                        {
                            break;
                        }
                        //--------------------模型
                        M_Plat_Mail mailMod = new M_Plat_Mail();
                        mailMod.UserID   = mu.UserID;
                        mailMod.Sender   = pop.GetSendMialAddress(i);
                        mailMod.Title    = pop.GetMailSubject(i);
                        mailMod.Receiver = pop.EmailAddress;
                        mailMod.Content  = pop.GetMailBodyAsText(i);
                        mailMod.CDate    = DateTime.Now;
                        mailMod.MailDate = sendtime;
                        mailMod.MailID   = mailid;
                        mailMod.Attach   = pop.GetMailAttach(i, ppath);
                        mailMod.Status   = 1;
                        mailBll.Insert(mailMod);
                    }
                    catch (Exception ex)
                    {
                        ZLLog.L("邮件接收异常,邮箱[" + pop.EmailAddress + "],原因:" + ex.Message);
                    }
                }
                pop.Pop3Close();
            }
            //------完成下载
            progMod.iscomplete       = true;
            progMod.index            = progMod.total;
            Session["Mail_DownProg"] = JsonConvert.SerializeObject(progMod);
        }
Exemplo n.º 5
0
        protected void BtnReply_Click(object sender, EventArgs e)
        {
            M_Plat_Mail mailMod = mailBll.SelReturnModel(MainID);

            Response.Redirect("MailWrite.aspx?reply=" + mailMod.ID);
        }