private void AddMemberToTreeview(string nodeName, IEnumerable <Linkman> linkmen) { if (!linkmen.Any()) { return; } var member = new TreeNode(nodeName + "(" + linkmen.Count() + ")"); member.SelectedImageIndex = 1; //member.NodeFont = new Font("微软雅黑", 9, FontStyle.Bold); TreeNode tmepNode; foreach (var item in linkmen) { tmepNode = new TreeNode(); tmepNode.SelectedImageIndex = 3; tmepNode.ImageIndex = 3; if (string.IsNullOrEmpty(item.InnerUser) && string.IsNullOrEmpty(item.Name)) { tmepNode.Tag = item.Mail; tmepNode.Text = item.Mail; } else if (!string.IsNullOrEmpty(item.Mail)) { tmepNode.Tag = item; tmepNode.Text = MailUtil.FormatToContacts(item.Name, item.Mail, false); } member.Nodes.Add(tmepNode); } tvLinkMan.Nodes.Add(member); }
protected virtual string GetReferenceStyle() { if (MailContext == null) { return(null); } var refer = new MailReference { Subject = MailContext.Subject, SentTime = MailContext.SentTime, Sender = MailUtil.FormatToContacts(MailContext.Sender) }; foreach (var str in MailContext.Recivers.Split(';')) { if (!string.IsNullOrEmpty(str)) { refer.Receivers.Add(MailUtil.FormatToContacts(str)); } } foreach (var str in MailContext.CC.Split(';')) { if (!string.IsNullOrEmpty(str)) { refer.CC.Add(MailUtil.FormatToContacts(str)); } } return(refer.FormatReference()); }
/// <summary> /// 窗体加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditorForm_Load(object sender, EventArgs e) { //初始化邮件配置对象 _config = MailCore.MF.MfMailConfig.GetMailConfig(_vault); if (!String.IsNullOrEmpty(_config.Email) && _config != null) { //发件人 lblSender.Text = MailUtil.FormatToContacts(_config.UserName, _config.Email, true); txtboxSubject.Text = _config.MarkUp + " "; } else { MessageBox.Show("未填写发件人邮箱地址,或邮箱设置未设置正确!"); this.Close(); } var mfMail = MailCore.MF.MessageFromMf.GetMailFromMf(_vault, _objId); _guidDraft = mfMail.Tag; var obj = MailFactory.CreateInstance(_actionType); obj.MailContext = mfMail; obj.MsgConfig = _config; var context = obj.GetMailContext(); if (!String.IsNullOrEmpty(_extAttachPath)) { //bimvision 生成的附件 context.AttachsPath.Add(_extAttachPath); } txtboxSubject.Text += context.Subject; lblSender.Text = context.Sender; txtboxReceiver.Text = context.Recivers; txtboxCC.Text = context.CC; if (context.AttachsPath != null) { foreach (var path in context.AttachsPath) { attachCtrl.AddAttachmentPath(path); } } editor.DocumentText = context.Content; //通讯录数据 SetLinkmanToTreeView(); }
/// <summary> /// 初始化搜索设置 /// </summary> private void InitSearch(IEnumerable <Linkman> linkmen) { if (!linkmen.Any()) { return; } // declare custom source. var source = new AutoCompleteStringCollection(); foreach (var t in linkmen) { source.Add(MailUtil.FormatToContacts(t.Name, t.Mail, true)); } txtSearch.AutoCompleteCustomSource = source; txtSearch.AutoCompleteMode = AutoCompleteMode.SuggestAppend; txtSearch.AutoCompleteSource = AutoCompleteSource.CustomSource; }
/// <summary> /// 格式化邮件联系人 /// </summary> /// <param name="value"></param> /// <returns></returns> private string CheckContacts(string value) { try { if (!Regex.IsMatch(value, EmailAddrExpression)) { if (Regex.IsMatch(value, EmailExpression)) { var str = value.Substring(0, value.IndexOf('@')); return(MailUtil.FormatToContacts(str, value, false)); } else { return(value); } } } catch (Exception) { } return(value); }
/// <summary> /// 双击节点讲选中节点对象的邮箱赋值给收件地址 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvLinkMan_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { var currentNode = (sender as TreeView).SelectedNode; var currentNodeCount = currentNode.GetNodeCount(false); var nodeTag = (sender as TreeView).SelectedNode.Tag; try { if (currentNodeCount == 0) { var lnkmanObj = (nodeTag as Linkman); _txtBox.Text += MailUtil.FormatToContacts(lnkmanObj.Name, lnkmanObj.Mail, true); } } catch (NullReferenceException a) { _txtBox.Text += nodeTag + ";"; } catch (Exception exception) { MessageBox.Show("该联系人没有设置邮箱!"); } }