我只想使用 Restrict-Method 过滤我的邮件,如下所示:
restriction += "[ReceivedTime] < '" + ((DateTime)time).ToString("yyyy-MM-dd HH:mm") + "'";
var count = oFolder.Items.Restrict(restriction).Count;//Cast<object>().ToList();
for (int i = 0; i < count; i++)
{
var crntReceivedTime = ((OutLook.MailItem)oFolder.Items.Restrict(restriction).Cast<object>().ToList()[i]).ReceivedTime;
if (crntReceivedTime > time)
{
string t = "";
}
}
从理论上讲,永远不应该调用该行string t = "";
,因为我确定 Items 永远不会有 ReceivedTime 的值大于time
. 问题是该行被调用,这意味着受限制的 Items Collection 包含其不应包含的条目。
我做错了什么还是Restrict()
- 方法失败了?