使用Exchange Web服务在c#中获取特定日期的电子邮件

前端之家收集整理的这篇文章主要介绍了使用Exchange Web服务在c#中获取特定日期的电子邮件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我可以根据主题从邮箱中获取电子邮件.我不确定根据收到的日期提取电子邮件的格式是什么?
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个项目,这些项目在您要查找的当天重新开始.

原文链接:https://www.f2er.com/html/226665.html

猜你在找的HTML相关文章