首页 新闻 会员 周边 捐助

C# OutLook 二次开发 获取当前选中的邮箱地址

0
悬赏园豆:10 [已解决问题] 解决于 2018-12-06 17:49

请问各位大神,如何获取Outlook界面当前选中的邮件的发件人地址呢?

我试了很多种方法都不行!

居~的主页 居~ | 初学一级 | 园豆:28
提问于:2018-04-09 17:39
< >
分享
最佳答案
0

/// <summary>
/// 获取运单号
/// </summary>
public List<string> GetMailItem()
{
List<string> Hawbs = new List<string>();
//Outlook._Application oApp = new Outlook.Application();
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
if (oApp.ActiveExplorer().Selection.Count > 0)
{
Object selObject = oApp.ActiveExplorer().Selection[1];

            if (selObject is Microsoft.Office.Interop.Outlook.MailItem)
            {
                Microsoft.Office.Interop.Outlook.MailItem mailItem = (selObject as Microsoft.Office.Interop.Outlook.MailItem);
                //String htmlBody = mailItem.HTMLBody;
                string Body = mailItem.Body.ToString();
                // string input = "18511999 1950 19052003";
                string pattern = @"[0-9]{10}";
                // MatchCollection match = Regex.Matches(Body, pattern);
                foreach (Match item in Regex.Matches(Body, pattern))
                {
                    Hawbs.Add(item.Value);
                }
                //for (int i = 0; i < match.Count; i++)
                //{
                //    Hawbs.Add(match[i].Value);
                //}
            }
        }

        return Hawbs;
    }
居~ | 初学一级 |园豆:28 | 2018-12-06 17:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册