VSTO for Microsoft Outlook Recipient Sort(收件人按字母顺序排序)

最近有这样一个需求,发邮件时To给谁谁但愿能按照字母顺序排序,避免没必要要的顾虑,你懂的数组

通过分析,1.须要找到读To 区域的方法 2.读取后分割字符串到数组 3. 通过数组排序后输出到To中ide


简单代码以下:blog

 MailItem mail = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as MailItem;排序

            string[] namelist = Regex.Split(mail.To,"; ",RegexOptions.IgnoreCase);字符串

            mail.To = null;get

            label1.Label = null;string

            Array.Sort(namelist);it

            foreach (string name in namelist)io

            {class

                label1.Label+= name + ';';

            }

            mail.To = label1.Label;


效果以下:

排序以前


wKioL1X7yAiwCmh6AAGohDR2Qh0998.jpg

按字母排序以后


wKiom1X7xc-yRZUSAADznTyhdsE720.jpg


因网上没有具体方法,特留做记录,以给须要的同窗作个参考