Exemple #1
0
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        ZWL.BLL.ERPNetEmail MyModel = new ZWL.BLL.ERPNetEmail();
        MyModel.EmailTitle   = this.TextBox1.Text;
        MyModel.EmailContent = this.TxtContent.Text;
        string filelist = ZWL.Common.PublicMethod.GetSessionValue("WenJianList");

        if (filelist != null && filelist != "")
        {
            MyModel.FuJian = ZWL.Common.PublicMethod.GetSessionValue("WenJianList");
        }
        else
        {
            MyModel.FuJian = null;
        }

        MyModel.FromUser   = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyModel.EmailState = "已发";
        MyModel.TimeStr    = DateTime.Now;
        MyModel.ToUser     = this.TextBox2.Text.Trim();

        try
        {
            //获取现有设置
            ZWL.BLL.ERPPOPAndSMTP MySMTPModel = new ZWL.BLL.ERPPOPAndSMTP();
            MySMTPModel.GetModel(int.Parse(ZWL.Common.PublicMethod.GetSessionValue("UserID")));
            //发送邮件到Internet地址

            //FengGu.Common.MailSender.Send(MySMTPModel.SMTPServer, MySMTPModel.SMTPFromEmail, MyModel.ToUser, MyModel.EmailTitle, MyModel.EmailContent, true, Encoding.UTF8, true, MyModel.FuJian);
            Pop3ForJmail.SendMail(MySMTPModel.SMTPUserName, MySMTPModel.SMTPUserPwd, MySMTPModel.SMTPServer, MyModel.EmailTitle, MyModel.EmailContent, MySMTPModel.SMTPFromEmail, MyModel.ToUser, MyModel.FuJian);

            MyModel.Add();

            ZWL.Common.MessageBox.ShowAndRedirect(this, "Internet邮件添加成功!", "NetMailShou.aspx");
        }
        catch
        {
            MyModel.EmailState = "草稿";

            MyModel.Add();

            Response.Write("<script>alert('发送邮件时发生错误,请检查您的邮件参数设置是否正确!已保存至草稿!');</script>");
        }
        //写系统日志
        ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
        MyRiZhi.UserName    = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyRiZhi.DoSomething = "用户添加新邮件(" + this.TextBox1.Text + ")";
        MyRiZhi.IpStr       = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
        MyRiZhi.Add();
    }
Exemple #2
0
    protected void ImageButton4_Click(object sender, EventArgs e)
    {
        //草稿
        ZWL.BLL.ERPNetEmail MyModel = new ZWL.BLL.ERPNetEmail();

        MyModel.EmailTitle   = this.TextBox1.Text;
        MyModel.EmailContent = this.TxtContent.Value;
        MyModel.FuJian       = ZWL.Common.PublicMethod.GetSessionValue("WenJianList");
        MyModel.FromUser     = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyModel.EmailState   = "草稿";
        MyModel.TimeStr      = DateTime.Now;
        string[] ToWhoList = this.TextBox2.Text.Trim().Split(',');
        for (int i = 0; i < ToWhoList.Length; i++)
        {
            if (ToWhoList[i].Trim().Length > 0)
            {
                MyModel.ToUser = ToWhoList[i].Trim();
                MyModel.Add();
            }
        }

        //写系统日志
        ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
        MyRiZhi.UserName    = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyRiZhi.DoSomething = "用户添加新邮件(" + this.TextBox1.Text + ")";
        MyRiZhi.IpStr       = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
        MyRiZhi.Add();

        ZWL.Common.MessageBox.ShowAndRedirect(this, "Internet邮件添加成功!", "NetMailShou.aspx");
    }
Exemple #3
0
    protected void ImageButton1_Click(object sender, EventArgs e)
    {
        ZWL.BLL.ERPNetEmail MyModel = new ZWL.BLL.ERPNetEmail();
        MyModel.EmailTitle   = this.TextBox1.Text;
        MyModel.EmailContent = this.TxtContent.Value;
        MyModel.FuJian       = ZWL.Common.PublicMethod.GetSessionValue("WenJianList");
        MyModel.FromUser     = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyModel.EmailState   = "已发";
        MyModel.TimeStr      = DateTime.Now;
        string[] ToWhoList = this.TextBox2.Text.Trim().Split(',');
        for (int i = 0; i < ToWhoList.Length; i++)
        {
            if (ToWhoList[i].Trim().Length > 0)
            {
                MyModel.ToUser = ToWhoList[i].Trim();
                MyModel.Add();

                //获取现有设置
                ZWL.BLL.ERPPOPAndSMTP MySMTPModel = new ZWL.BLL.ERPPOPAndSMTP();
                MySMTPModel.GetModel(int.Parse(ZWL.Common.PublicMethod.GetSessionValue("UserID")));
                //发送邮件到Internet地址
                try
                {
                    Pop3ForJmail.SendMail(MySMTPModel.SMTPUserName, MySMTPModel.SMTPUserPwd, MySMTPModel.SMTPServer, MyModel.EmailTitle, MyModel.EmailContent, MySMTPModel.SMTPFromEmail, MyModel.ToUser, MyModel.FuJian);
                }
                catch
                {
                    Response.Write("<script>alert('发送邮件时发生错误,请检查您的邮件参数设置是否正确!');</script>");
                }
            }
        }
        //写系统日志
        ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
        MyRiZhi.UserName    = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyRiZhi.DoSomething = "用户添加新邮件(" + this.TextBox1.Text + ")";
        MyRiZhi.IpStr       = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
        MyRiZhi.Add();

        ZWL.Common.MessageBox.ShowAndRedirect(this, "Internet邮件添加成功!", "NetMailShou.aspx");
    }
Exemple #4
0
    protected void ImageButton1_Click(object sender, EventArgs e)
    {
        ZWL.BLL.ERPNetEmail MyModel = new ZWL.BLL.ERPNetEmail();
        MyModel.EmailTitle = this.TextBox1.Text;
        MyModel.EmailContent = this.TxtContent.Value;
        MyModel.FuJian = ZWL.Common.PublicMethod.GetSessionValue("WenJianList");
        MyModel.FromUser = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyModel.EmailState = "已发";
        MyModel.TimeStr = DateTime.Now;
        string[] ToWhoList = this.TextBox2.Text.Trim().Split(',');
        for (int i = 0; i < ToWhoList.Length; i++)
        {
            if (ToWhoList[i].Trim().Length > 0)
            {
                MyModel.ToUser = ToWhoList[i].Trim();
                MyModel.Add();

                //获取现有设置
                ZWL.BLL.ERPPOPAndSMTP MySMTPModel = new ZWL.BLL.ERPPOPAndSMTP();
                MySMTPModel.GetModel(int.Parse(ZWL.Common.PublicMethod.GetSessionValue("UserID")));
                //发送邮件到Internet地址
                try
                {
                    Pop3ForJmail.SendMail(MySMTPModel.SMTPUserName, MySMTPModel.SMTPUserPwd, MySMTPModel.SMTPServer, MyModel.EmailTitle, MyModel.EmailContent, MySMTPModel.SMTPFromEmail, MyModel.ToUser, MyModel.FuJian);
                }
                catch
                {
                    Response.Write("<script>alert('发送邮件时发生错误,请检查您的邮件参数设置是否正确!');</script>");
                }
            }
        }
        //写系统日志
        ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
        MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyRiZhi.DoSomething = "用户添加新邮件(" + this.TextBox1.Text + ")";
        MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
        MyRiZhi.Add();

        ZWL.Common.MessageBox.ShowAndRedirect(this, "Internet邮件添加成功!", "NetMailShou.aspx");
    }
Exemple #5
0
    /// <summary>
    /// 收取新邮件、不删除老邮件、收取邮件后写入数据库
    /// </summary>
    public static void GetNewMailIntoDataBase(string UserName, string PassWord, string PopServer, int Port, DateTime MaxDate)
    {
        POP3 NewMail = new POP3();

        NewMail.Connect(UserName, PassWord, PopServer, Port);
        for (int i = 1; i <= NewMail.Count; i++)
        {
            //判断是否跟当前最大的时间作比较,大于当前时间就处理
            DateTime CurrentEmailDate = DateTime.Now;
            try
            {
                CurrentEmailDate = DateTime.Parse(NewMail.Messages[i].Date.ToString());
            }
            catch
            { }

            try
            {
                if (CurrentEmailDate.CompareTo(MaxDate) > 0)
                {
                    string EmailFuJian = "";
                    for (int j = 0; j < NewMail.Messages[i].Attachments.Count; j++)
                    {
                        NewMail.Messages[i].Charset          = "GB2312"; //设置邮件的编码方式
                        NewMail.Messages[i].Encoding         = "Base64"; //设置邮件的附件编码方式
                        NewMail.Messages[i].ISOEncodeHeaders = false;    //是否将信头编码成iso-8859-1字符集



                        try
                        {
                            string FileName = DateTime.Now.Ticks.ToString() + NewMail.Messages[i].Attachments[j].Name;
                            //符合上传要求就保存,否则提示文件名未下载
                            if (ZWL.Common.PublicMethod.IfOkFile(FileName) == true)
                            {
                                NewMail.Messages[i].Attachments[j].SaveToFile(System.Web.HttpContext.Current.Request.MapPath("../UploadFile") + "\\MailAttachments\\" + FileName);
                            }
                            else
                            {
                                System.Web.HttpContext.Current.Response.Write("<script>alert('邮件附件文件:" + NewMail.Messages[i].Attachments[j].Name + " 不符合本服务器文件保存权限设置,禁止下载!已自动跳过本附件!');</script>");
                            }
                            if (EmailFuJian.Trim().Length > 0)
                            {
                                EmailFuJian = EmailFuJian + "|MailAttachments/" + FileName;
                            }
                            else
                            {
                                EmailFuJian = "MailAttachments/" + FileName;
                            }
                        }
                        catch (Exception e)
                        {
                            System.Web.HttpContext.Current.Response.Write("<script>alert('" + e.Message.ToString() + "');</script>");
                        }
                    }

                    ZWL.BLL.ERPNetEmail MyModel = new ZWL.BLL.ERPNetEmail();
                    MyModel.EmailContent = NewMail.Messages[i].Body;
                    MyModel.EmailState   = "未读";
                    MyModel.EmailTitle   = NewMail.Messages[i].Subject;
                    MyModel.FromUser     = NewMail.Messages[i].FromName + "(" + NewMail.Messages[i].From + ")";
                    MyModel.FuJian       = EmailFuJian;
                    try
                    {
                        MyModel.TimeStr = DateTime.Parse(NewMail.Messages[i].Date.ToString());
                    }
                    catch
                    {
                        MyModel.TimeStr = DateTime.Now;
                    }
                    MyModel.ToUser = ZWL.Common.PublicMethod.GetSessionValue("UserName");

                    MyModel.Add();
                }
            }
            catch (Exception ee)
            {
                System.Web.HttpContext.Current.Response.Write("<script>alert('" + ee.Message.ToString() + "');</script>");
            }
        }
        NewMail.Disconnect();
    }
Exemple #6
0
    /// <summary>
    /// 收取新邮件、不删除老邮件、收取邮件后写入数据库
    /// </summary>
    public static void GetNewMailIntoDataBase(string UserName,string PassWord,string PopServer,int Port,DateTime MaxDate)
    {
        POP3 NewMail = new POP3();

        NewMail.Connect(UserName, PassWord, PopServer, Port);
        for (int i = 1; i <= NewMail.Count; i++)
        {
            //判断是否跟当前最大的时间作比较,大于当前时间就处理
            DateTime CurrentEmailDate = DateTime.Now;
            try
            {
                CurrentEmailDate = DateTime.Parse(NewMail.Messages[i].Date.ToString());
            }
            catch
            { }

            try
            {
                if (CurrentEmailDate.CompareTo(MaxDate) > 0)
                {
                    string EmailFuJian = "";
                    for (int j = 0; j < NewMail.Messages[i].Attachments.Count; j++)
                    {

                        NewMail.Messages[i].Charset = "GB2312"; //设置邮件的编码方式
                        NewMail.Messages[i].Encoding = "Base64"; //设置邮件的附件编码方式
                        NewMail.Messages[i].ISOEncodeHeaders = false; //是否将信头编码成iso-8859-1字符集

                        try
                        {
                            string FileName = DateTime.Now.Ticks.ToString() + NewMail.Messages[i].Attachments[j].Name;
                            //符合上传要求就保存,否则提示文件名未下载
                            if (ZWL.Common.PublicMethod.IfOkFile(FileName) == true)
                            {
                                NewMail.Messages[i].Attachments[j].SaveToFile(System.Web.HttpContext.Current.Request.MapPath("../UploadFile") + "\\MailAttachments\\" + FileName);
                            }
                            else
                            {
                                System.Web.HttpContext.Current.Response.Write("<script>alert('邮件附件文件:" + NewMail.Messages[i].Attachments[j].Name + " 不符合本服务器文件保存权限设置,禁止下载!已自动跳过本附件!');</script>");
                            }
                            if (EmailFuJian.Trim().Length > 0)
                            {
                                EmailFuJian = EmailFuJian + "|MailAttachments/" + FileName;
                            }
                            else
                            {
                                EmailFuJian = "MailAttachments/" + FileName;
                            }
                        }
                        catch (Exception e)
                        {
                            System.Web.HttpContext.Current.Response.Write("<script>alert('" + e.Message.ToString() + "');</script>");
                        }
                    }

                    ZWL.BLL.ERPNetEmail MyModel = new ZWL.BLL.ERPNetEmail();
                    MyModel.EmailContent = NewMail.Messages[i].Body;
                    MyModel.EmailState = "未读";
                    MyModel.EmailTitle = NewMail.Messages[i].Subject;
                    MyModel.FromUser = NewMail.Messages[i].FromName + "(" + NewMail.Messages[i].From + ")";
                    MyModel.FuJian = EmailFuJian;
                    try
                    {
                        MyModel.TimeStr = DateTime.Parse(NewMail.Messages[i].Date.ToString());
                    }
                    catch
                    {
                        MyModel.TimeStr = DateTime.Now;
                    }
                    MyModel.ToUser = ZWL.Common.PublicMethod.GetSessionValue("UserName");

                    MyModel.Add();
                }
            }
            catch (Exception ee)
            {
                System.Web.HttpContext.Current.Response.Write("<script>alert('" + ee.Message.ToString() + "');</script>");
            }
        }
        NewMail.Disconnect();
    }
Exemple #7
0
    protected void ImageButton4_Click(object sender, EventArgs e)
    {
        //草稿
        ZWL.BLL.ERPNetEmail MyModel = new ZWL.BLL.ERPNetEmail();

        MyModel.EmailTitle = this.TextBox1.Text;
        MyModel.EmailContent = this.TxtContent.Value;
        MyModel.FuJian = ZWL.Common.PublicMethod.GetSessionValue("WenJianList");
        MyModel.FromUser = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyModel.EmailState = "草稿";
        MyModel.TimeStr = DateTime.Now;
        string[] ToWhoList = this.TextBox2.Text.Trim().Split(',');
        for (int i = 0; i < ToWhoList.Length; i++)
        {
            if (ToWhoList[i].Trim().Length > 0)
            {
                MyModel.ToUser = ToWhoList[i].Trim();
                MyModel.Add();
            }
        }

        //写系统日志
        ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
        MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName");
        MyRiZhi.DoSomething = "用户添加新邮件(" + this.TextBox1.Text + ")";
        MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
        MyRiZhi.Add();

        ZWL.Common.MessageBox.ShowAndRedirect(this, "Internet邮件添加成功!", "NetMailShou.aspx");
    }
Exemple #8
0
    /// <summary>
    /// 收取新邮件、不删除老邮件、收取邮件后写入数据库
    /// </summary>
    public static void GetNewMailIntoDataBase(string UserName, string PassWord, string PopServer, int Port, DateTime MaxDate)
    {
        POP3 NewMail = new POP3();

        NewMail.Connect(UserName, PassWord, PopServer, Port);
        for (int i = 1; i <= NewMail.Count; i++)
        {
            //判断是否跟当前最大的时间作比较,大于当前时间就处理
            DateTime CurrentEmailDate = DateTime.Now;
            try
            {
                CurrentEmailDate = DateTime.Parse(NewMail.Messages[i].Date.ToString());
            }
            catch
            { }

            try
            {
                if (CurrentEmailDate.CompareTo(MaxDate) > 0)
                {
                    string EmailFuJian = "";
                    for (int j = 0; j < NewMail.Messages[i].Attachments.Count; j++)
                    {
                        try
                        {
                            string FileName = DateTime.Now.Ticks.ToString() + NewMail.Messages[i].Attachments[j].Name;
                            NewMail.Messages[i].Attachments[j].SaveToFile(System.Web.HttpContext.Current.Request.MapPath("../UploadFile") + "\\MailAttachments\\" + FileName);
                            if (EmailFuJian.Trim().Length > 0)
                            {
                                EmailFuJian = EmailFuJian + "|MailAttachments/" + FileName;
                            }
                            else
                            {
                                EmailFuJian = "MailAttachments/" + FileName;
                            }
                        }
                        catch (Exception e)
                        {
                            System.Web.HttpContext.Current.Response.Write("<script>alert('" + e.Message.ToString() + "');</script>");
                        }
                    }

                    ZWL.BLL.ERPNetEmail MyModel = new ZWL.BLL.ERPNetEmail();
                    MyModel.EmailContent = NewMail.Messages[i].Body;
                    MyModel.EmailState   = "未读";
                    MyModel.EmailTitle   = NewMail.Messages[i].Subject;
                    MyModel.FromUser     = NewMail.Messages[i].FromName + "(" + NewMail.Messages[i].From + ")";
                    MyModel.FuJian       = EmailFuJian;
                    try
                    {
                        MyModel.TimeStr = DateTime.Parse(NewMail.Messages[i].Date.ToString());
                    }
                    catch
                    {
                        MyModel.TimeStr = DateTime.Now;
                    }
                    MyModel.ToUser = ZWL.Common.PublicMethod.GetSessionValue("UserName");

                    MyModel.Add();
                }
            }
            catch (Exception ee)
            {
                System.Web.HttpContext.Current.Response.Write("<script>alert('" + ee.Message.ToString() + "');</script>");
            }
        }
        NewMail.Disconnect();
    }