Esempio n. 1
0
        private void bOk_Click(object sender, EventArgs e)
        {
            pop3 = new POP3(Host, Port, U, P);

            DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 2
0
 public MainWindow()
 {
     InitializeComponent();
     mPOP3 = new POP3(ListBoxEvents);
     ic    = new ImapClient(ListBoxEvents);
     socksHelperforSmtp = new SocksHelper(ListBoxEvents);
 }
 private bool POP3IsConnectedGet(POP3 pop3)
 {
     if (_testContext.POP3IsConnectedExceptionToThrow != null)
     {
         var exception = _testContext.POP3IsConnectedExceptionToThrow;
         _testContext.POP3IsConnectedExceptionToThrow = null;
         throw exception;
     }
     return(_testContext.POP3IsConnectedReturnValue);
 }
        private void POP3SaveToFile(POP3 pop3, int index, string filePath)
        {
            _testContext.POP3SaveToFileCalled = true;
            var exception = _testContext.POP3SaveToFileExceptionToThrow;

            if (exception != null)
            {
                _testContext.POP3SaveToFileExceptionToThrow = null;
                throw exception;
            }
        }
Esempio n. 5
0
        protected void ButtonDownload_Click(object sender, EventArgs e)
        {
            String[] contextId = Request.QueryString.GetValues("context");
            String[] sourceEnt = Request.QueryString.GetValues("source");
            String[] destEnt   = Request.QueryString.GetValues("destination");


            DataTable dt = new DataTable();

            dt.Columns.Add("attachment");

            POP3 pop3Client = (POP3)Session[SessionFactory.POP3_CLIENT_OBJECT];

            pop3Client = getPop3Connection();
            //if (!pop3Client.IsConnected)
            //pop3Client.Connect();

            MimeMessage        msg            = pop3Client.GetMessage(int.Parse(LabelSelectedGridItem.Text.ToString()) - 1);
            MimePartCollection mimeCollc      = msg.MimeParts;
            String             attachmentName = "";

            String downloadReadyMsg = contextId[0] + "-" + sourceEnt[0] + "-" + destEnt[0] + "-" + SessionFactory.ALL_COMM_DOWNLOADABLE_MSG;

            Session[downloadReadyMsg] = msg;

            /*for (int i = 0; i < mimeCollc.Count; i++)
             * {
             *  if (mimeCollc[i].IsAttachment())
             *      attachmentName += attachmentName.Equals("") ? mimeCollc[i].AttachmentName() : "," + mimeCollc[i].AttachmentName();
             * }*/

            attachmentName = LabelAttachList.Text;
            String[] attachmentNameArray = attachmentName.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            if (attachmentNameArray.Length == 1)
            {
                DownloadAttachment(msg, attachmentName);
            }

            else
            {
                for (int i = 0; i < attachmentNameArray.Length; i++)
                {
                    dt.Rows.Add();
                    dt.Rows[i]["attachment"] = attachmentNameArray[i];
                }

                PanelDownload.Visible          = true;
                GridView_Attachment.Visible    = true;
                GridView_Attachment.DataSource = dt;
                GridView_Attachment.DataBind();
            }
        }
 private string POP3GetMessageAsText(POP3 pop3, int messageIndex)
 {
     _testContext.POP3GetMessageAsTextCalled = true;
     _testContext.POP3InboxMessageCountReturnValue--;
     if (_testContext.POP3GetMessageAsTextShouldThrowException)
     {
         _testContext.POP3GetMessageAsTextShouldThrowException = false;
         throw new Exception();
     }
     if (_testContext.POP3GetMessageAsTextShouldReturnNull)
     {
         return(null);
     }
     return(_testContext.POP3GetMessageAsTextReturnValue);
 }
Esempio n. 7
0
        public POP3 getPop3Connection()
        {
            String Pop3URL = "pop.gmail.com";
            String id      = "*****@*****.**";
            String pass    = "******";

            POP3.LoadLicenseFile("E:\\Softwares\\EmailAsp.net\\aspNetPOP3\\aspNetPOP3.xml.lic");
            POP3 pop3Client = new POP3(Pop3URL, id, pass, 995);

            AdvancedIntellect.Ssl.SslSocket ssl = new AdvancedIntellect.Ssl.SslSocket();
            pop3Client.LoadSslSocket(ssl);

            pop3Client.Connect();

            return(pop3Client);
        }
Esempio n. 8
0
        private void UpdateMailList()
        {
            ResultDownloadMessages result;

            while (true)
            {
                if (lastReceivedMail.Count == 0)
                {
                    result = POP3.DownloadMessages(serverName, serverPort, username, password);

                    if (result.Success == true)
                    {
                        textBoxStart.Invoke(new Action(() => textBoxStart.Text = result.ReceivedMails.Length.ToString()));
                    }
                }
                else
                {
                    result = POP3.DownloadMessages(serverName, serverPort, username, password, lastReceivedMail.ToArray());
                }

                if (result.Success)
                {
                    lastReceivedMail.AddRange(result.ReceivedMails);

                    foreach (var mail in result.ReceivedMails)
                    {
                        listBoxMessages.Invoke((new Action(() => listBoxMessages.Items.Add(mail.ToString()))));
                    }

                    textBoxCurrent.Invoke(new Action(() => textBoxCurrent.Text = listBoxMessages.Items.Count.ToString()));

                    if (result.ReceivedMails.Length != 0)
                    {
                        MessageBox.Show("You have new message/messages.");
                    }
                }
                else
                {
                    MessageBox.Show(result.Message);
                }

                Thread.Sleep(updateTime);
            }
        }
 private void POP3Disconnect(POP3 pop3)
 {
     _testContext.POP3DisconnectCalled = true;
     if (_testContext.POP3DisconnectShouldThrowException)
     {
         _testContext.POP3DisconnectShouldThrowException = false;
         throw new Exception();
     }
     if (_testContext.POP3DisconnectShouldThrowOutOfMemoryException)
     {
         _testContext.POP3DisconnectShouldThrowOutOfMemoryException = false;
         throw new OutOfMemoryException();
     }
     if (_testContext.POP3DisconnectShouldThrowPOP3Exception)
     {
         _testContext.POP3DisconnectShouldThrowPOP3Exception = false;
         throw new POP3Exception();
     }
 }
 private int POP3InboxMessageCountGet(POP3 pop3)
 {
     return(_testContext.POP3InboxMessageCountReturnValue);
 }
 private void BounceEngineDeleteMessageWithCheck(POP3 pop3, int messageIndex)
 {
     _testContext.BounceEngineDeleteMessageWithCheckCalled = true;
 }
Esempio n. 12
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();
    }
 private void POP3TimeOutSet(POP3 pop3, int timeout)
 {
     _testContext.POP3TimeoutSet = true;
 }
Esempio n. 14
0
        protected void LinkButton_Subject_Command1(object sender, CommandEventArgs e)
        {
            try
            {
                GridView_Email.SelectedIndex = int.Parse(e.CommandArgument.ToString());
                LabelSelectedGridItem.Text   = ((Label)GridView_Email.Rows[int.Parse(e.CommandArgument.ToString())].Cells[0].FindControl("Label_Hidden")).Text;

                POP3     pop3Client = (POP3)Session[SessionFactory.POP3_CLIENT_OBJECT];
                String[] contextId  = Request.QueryString.GetValues("context");
                String[] sourceEnt  = Request.QueryString.GetValues("source");
                String[] destEnt    = Request.QueryString.GetValues("destination");

                String cacheKey = contextId[0] + "-" + sourceEnt[0] + "-" + destEnt[0];

                String index = ((Label)GridView_Email.Rows[int.Parse(e.CommandArgument.ToString())].Cells[0].FindControl("Label_Hidden")).Text;

                if (((Dictionary <String, String>)Cache.Get(cacheKey + "-" + "msg")).ContainsKey((float.Parse(index) - 1).ToString()))
                {
                    TextBox_MsgBody.Text = ((Dictionary <String, String>)Cache.Get(cacheKey + "-" + "msg"))[(float.Parse(index) - 1).ToString()];
                    LabelAttachList.Text = ((Dictionary <String, String>)Cache.Get(cacheKey + "-" + "attach"))[(float.Parse(index) - 1).ToString()];
                }
                else
                {
                    //Message not in cache..pull from server
                    if (!pop3Client.IsConnected)
                    {
                        pop3Client.Connect();
                        Session[SessionFactory.POP3_CLIENT_OBJECT] = pop3Client;
                    }
                    MimeMessage msg = pop3Client.GetMessage(int.Parse(index) - 1);

                    Dictionary <String, String> cacheMsgDict    = (Dictionary <String, String>)Cache.Get(cacheKey + "-" + "msg");
                    Dictionary <String, String> cacheAttachDict = (Dictionary <String, String>)Cache.Get(cacheKey + "-" + "attach");

                    String messageText    = msg.TextMimePart.ToString();
                    String attachmentName = "";

                    MimePartCollection mimePartCollc = msg.MimeParts;
                    for (int j = 0; j < mimePartCollc.Count; j++)
                    {
                        if (mimePartCollc[j].IsAttachment())
                        {
                            attachmentName = attachmentName.Equals("") ? mimePartCollc[j].AttachmentName() :
                                             attachmentName + "," + mimePartCollc[j].AttachmentName();
                        }
                    }

                    cacheMsgDict.Add((int.Parse(index) - 1).ToString(), messageText);
                    cacheAttachDict.Add((int.Parse(index) - 1).ToString(), attachmentName);

                    Cache.Insert(cacheKey + "-" + "msg", cacheMsgDict);
                    Cache.Insert(cacheKey + "-" + "attach", cacheAttachDict);

                    TextBox_MsgBody.ForeColor = System.Drawing.Color.Black;

                    TextBox_MsgBody.Text = messageText;
                    LabelAttachList.Text = attachmentName;
                }
            }
            catch (Exception ex)
            {
                TextBox_MsgBody.Text      = "Error Retrieving Message Content";
                TextBox_MsgBody.ForeColor = System.Drawing.Color.Red;
            }
        }
Esempio n. 15
0
        protected void ReceiveMails()
        {
            POP3 pop3Client = getPop3Connection();
            int  msgCount   = pop3Client.MessageCount();


            String[] contextId = Request.QueryString.GetValues("context");
            String[] sourceEnt = Request.QueryString.GetValues("source");
            String[] destEnt   = Request.QueryString.GetValues("destination");

            String cacheKey = contextId[0] + "-" + sourceEnt[0] + "-" + destEnt[0];
            Dictionary <String, String> cacheMsgDict    = new Dictionary <String, String>();
            Dictionary <String, String> cacheAttachDict = new Dictionary <String, String>();

            DataTable dt        = new DataTable();
            DataTable dtSession = (DataTable)Session[cacheKey];
            Dictionary <String, String> refreshCheck = new Dictionary <String, String>();

            dt.Columns.Add("Hidden");
            dt.Columns.Add("Sender");
            dt.Columns.Add("RecvDate");
            dt.Columns.Add("Subject");


            int msgCounter = 0;

            for (int i = msgCount; i > (msgCount - GridView_Email.PageSize); i--)
            {
//                if (((Dictionary<String, String>)Cache.Get(cacheKey + "-" + "msg") ==null||((Dictionary<String, String>)Cache.Get(cacheKey + "-" + "msg")).Count==0)
                //               || !((Dictionary<String, String>)Cache.Get(cacheKey + "-" + "msg")).ContainsKey((i - 1).ToString()))
                //      {

                MimeMessage msg = pop3Client.GetMessage(i - 1);
                if (i > (msgCount - 1))
                {
                    Boolean messageInCache = false;

                    if (((Dictionary <String, String>)Cache.Get(cacheKey + "-" + "msg")) != null && ((Dictionary <String, String>)Cache.Get(cacheKey + "-" + "msg")).ContainsKey((i - 1).ToString()))
                    {
                        messageInCache = true;
                    }

                    if (!messageInCache)
                    {
                        MimePartCollection allMimeParts   = msg.MimeParts;
                        String             messageText    = "";
                        String             attachmentName = "";

                        if (msg.TextMimePart != null)
                        {
                            messageText += msg.TextMimePart.ToString();
                        }
                        else
                        {
                            messageText = "";
                        }

                        if (i == msgCount)
                        {
                            TextBox_MsgBody.Text = msg.TextMimePart.ToString();
                        }
                        //MessagBodyHTML.InnerHtml = msg.TextMimePart.ToString();

                        for (int j = 0; j < allMimeParts.Count; j++)
                        {
                            if (allMimeParts[j].IsAttachment())
                            {
                                if (i == msgCount)
                                {
                                    LabelAttachList.Text += LabelAttachList.Text.Equals("") ? allMimeParts[j].AttachmentName() : "," + allMimeParts[j].AttachmentName();
                                }
                                attachmentName += attachmentName.Equals("") ? allMimeParts[j].AttachmentName() : "," + allMimeParts[j].AttachmentName();
                            }
                        }

                        cacheMsgDict.Add((i - 1).ToString(), messageText);
                        cacheAttachDict.Add((i - 1).ToString(), attachmentName);
                    }
                }
                if (msg != null)
                {
                    dt.Rows.Add();
                    dt.Rows[msgCounter]["Hidden"]   = i.ToString();
                    dt.Rows[msgCounter]["Sender"]   = msg.From.EmailAddress;
                    dt.Rows[msgCounter]["RecvDate"] = msg.ReceivedDate().Date;
                    dt.Rows[msgCounter]["Subject"]  = msg.Subject.ToString();

                    refreshCheck.Add(i.ToString(), i.ToString());

                    msgCounter++;
                }
            }


            Cache.Insert(cacheKey + "-" + "msg", cacheMsgDict);
            Cache.Insert(cacheKey + "-" + "attach", cacheAttachDict);
            Cache.Insert(cacheKey, dt);

            Session[SessionFactory.POP3_CLIENT_OBJECT] = pop3Client;

            //Now append the already existing datatable from session (if any)
            int rowCountIndex = dt.Rows.Count;
            int counter       = 0;

            if (dtSession != null)
            {
                for (int j = 0; j < dtSession.Rows.Count; j++)
                {
                    if (!refreshCheck.ContainsKey(dtSession.Rows[j]["Hidden"].ToString()))
                    {
                        dt.Rows.Add();
                        dt.Rows[rowCountIndex + counter]["Hidden"]   = dtSession.Rows[counter]["Hidden"];
                        dt.Rows[rowCountIndex + counter]["Sender"]   = dtSession.Rows[counter]["Sender"];
                        dt.Rows[rowCountIndex + counter]["RecvDate"] = dtSession.Rows[counter]["RecvDate"];
                        dt.Rows[rowCountIndex + counter]["Subject"]  = dtSession.Rows[counter]["Subject"];

                        counter++;
                    }
                }
            }

            GridView_Email.Visible    = true;
            GridView_Email.DataSource = dt;
            GridView_Email.DataBind();
            GridView_Email.Columns[0].Visible = false;
            GridView_Email.SelectedIndex      = 0;
            LabelSelectedGridItem.Text        = ((Label)GridView_Email.Rows[0].Cells[0].FindControl("Label_Hidden")).Text;
            Session[cacheKey] = dt;
        }
 private void POP3PopulateInboxStats(POP3 pop3)
 {
     _testContext.POP3PopulateInboxStatsCalled = true;
 }
 private void POP3Connect(POP3 pop3)
 {
     _testContext.POP3ConnectCalled = true;
 }
 private void POP3CancelDeletes(POP3 pop3)
 {
     _testContext.POP3CancelDeletesCalled = true;
 }
Esempio n. 19
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();
    }
 private void POP3Constructor(POP3 pop3, string server, string userName, string password)
 {
 }
Esempio n. 21
0
        protected void ButtonRun_Click(object sender, EventArgs e)
        {
            var pop = new POP3("mail.siliconvalley-codecamp.com", Utils.GetServiceEmailAddress(), "walnut95");

            // need to move this to appconfig at some point   todo
            //var pop = new POP3("pop.secureserver.net", "*****@*****.**", "walnut95") { Port = 995 };

            //var ssl = new AdvancedIntellect.Ssl.SslSocket();
            //pop.LoadSslSocket(ssl);

            pop.LogInMemory = true;
            pop.Connect();
            int messageCount = pop.MessageCount();

            for (int i = 0; i < messageCount; i++)
            {
                if (i > Convert.ToInt32(TextBoxMaxCnt.Text)) break;
                var messageText = pop.GetMessageAsText(i);
                bool deleteMessage = ProcessMessage(messageText);
                if (deleteMessage)
                {
                    pop.Delete(i);
                }
            }
            pop.CommitDeletes();

            pop.Disconnect();

            var recs = from data in _mailResults
                       where data.WillDelete
                       group data by data.MessageType
                           into g
                           select new MailResultGroups()
                           {
                               Counter = g.Count(),
                               NDRTypeString = ConvertNDRTypeToString(g.Key)
                           };

            GridViewTotals.DataSource = recs.OrderBy(a => a.NDRTypeString).ToList();
            GridViewTotals.DataBind();

            GridViewResults.DataSource = _mailResults.Where(a => a.WillDelete);
            GridViewResults.DataBind();
        }
Esempio n. 22
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();
    }