/// <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;
}