Esempio n. 1
0
 public frmAccount(frmMessage frmFather )
 {
     InitializeComponent();
     formFather = frmFather;
     //HUYLX : Set thông tin cấu hình
     UserMail =FrameworkParams.currentUser.username + "@" + Connect.domain;
     Password = FrameworkParams.currentUser.id + "_protocolvn";
     UserId = FrameworkParams.currentUser.id.ToString();
     frmAccount_load();
     cbTaiKhoan.EditValueChanged += new EventHandler(cbTaiKhoan_EditValueChanged);
     EnableControl(false);
     EnableButtonOpe(true);
     btnSua.Enabled = false;
     btnXoa.Enabled = false;
 }
        //state = "Reply" or "Forward" or "Drafts"
        public frmNewMessage(Email mail, string state,frmMessage form)
        {
            InitializeComponent();
            UserMail = FrameworkParams.currentUser.username + "@" + Connect.domain;
            //HUYLX : Set lại password từ framework
            //Password = FrameworkParams.currentUser.password;
            Password = FrameworkParams.currentUser.id + "_protocolvn";
            UserId = FrameworkParams.currentUser.id.ToString();
            this.state = state;
            if ((state == "Reply") | (state == "Forward"))
            {
                string to = "";
                for (int i = 0; i < mail.NumTo; i++)
                    to += mail.GetTo(i);

                string stringHTML = mail.GetHtmlBody();
                if ((mail.HasHtmlBody()) & (mail.NumRelatedItems > 0))//show image
                {
                    string path = FrameworkParams.TEMP_FOLDER + @"\MailImage";
                    if (!System.IO.Directory.Exists(path))
                    {
                        System.IO.Directory.CreateDirectory(path);
                    }
                    for (int i = 0; i < mail.NumRelatedItems; i++)
                    {
                        mail.SaveRelatedItem(i, path);
                        string replace = mail.GetRelatedContentID(i);
                        int pos = stringHTML.IndexOf(replace);
                        pos--;
                        while (stringHTML[pos].ToString() != "\"")
                        {
                            replace = stringHTML[pos].ToString() + replace;
                            pos--;
                        }
                        stringHTML = stringHTML.Replace(replace, path + "\\\\" + mail.GetRelatedFilename(i));
                    }
                }
                editor.DocumentText = "<HTML><BODY>"
                                               + "</br>" + "</br>"
                                               + "------------- Thư gốc ------------- </br>"
                                               + "Từ: " + mail.From + "</br>"
                                               + "Ngày: " + mail.EmailDate.ToString() + "</br>"
                                               + "Tiêu đề: " + mail.Subject + "</br>"
                                               + "Đến: " + to + "</br>" + "</br>"
                                               + "Nội dung: </br>" + ((mail.HasHtmlBody()) ? stringHTML : mail.GetPlainTextBody())
                                               + "</BODY></HTML>";
                if (state == "Reply")
                {
                    Mail = mail.CreateReply();

                }
                else
                {
                    if (state == "Forward")
                        Mail = mail.CreateForward();
                    else
                        Mail = mail;
                }
            }
            numOfOldAttach = Mail.NumAttachments;
            parentForm = form;
            _initAtt();
            loadmail();
            LoadPlugin();
        }