我可以根据主题从邮箱中获取电子邮件.我不确定根据收到的日期提取电子邮件的格式是什么?
string message = string.Empty; Item item = Item.Bind(exService,messageID,PropertySet.FirstClassProperties); if (item is EmailMessage) { EmailMessage em = (EmailMessage)item; string strMsg = string.Empty; //strMsg = strMsg + item.Id.ToString(); //strMsg = strMsg + item.DateTimeReceived; strMsg = strMsg + "*********************** New Fiscal Email received on " + item.DateTimeReceived +" ************************************" + Environment.NewLine; if (em.Body.Text.Contains("BRANDON")) { strMsg = strMsg + em.Body.Text.ToString(); } strMsg = strMsg + "*********************** End of Email Body ************************************" + Environment.NewLine; message = strMsg; }
解决方法
我认为SilverNinja告诉你的方式是正确的.
你应该搜索这样的项目:
你应该搜索这样的项目:
DateTime searchdate = new DateTime (2012,7,6) //Year,month,day SearchFilter greaterthanfilter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived,searchdate ); SearchFilter lessthanfilter = new SearchFilter.IsLessThan(ItemSchema.DateTimeReceived,searchdate.AddDays(1)); SearchFilter filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And,greaterthanfilter,lessthanfilter); Folder folder = Folder.Bind(this.m_Service,WellKnownFolderName.MsgFolderRoot); //Or the folder you want to search in FindItemsResults<Item> results = folder.FindItems(filter,new ItemView(1000));
“results.Items”将返回前1000个项目,这些项目在您要查找的当天重新开始.