擅长:python、mysql、java
<p>COM API文档相当全面,您可以看到类列表,例如<a href="https://msdn.microsoft.com/en-us/library/office/ff863329.aspx" rel="nofollow noreferrer">here</a>。它还记录了可以用来操作它拥有的对象的各种方法。在您的特定示例中,您所追求的是通过日期限制您的项集。在items类<a href="https://msdn.microsoft.com/en-us/library/office/ff869597.aspx" rel="nofollow noreferrer">here</a>中,您将看到已经有一个用于此的函数。这就叫限制。我能看到的唯一一个问题是,你需要以字符串形式指定你想要的过滤器,从而要求你自己构造字符串。</p>
<p>例如,要继续执行代码并按时间限制:</p>
<pre><code>#first create the string filter, here you would like to filter on sent time
#assuming you wanted emails after 5 pm as an example and your date d from the code above
sFilter = "[SentOn] > '{0} 5:00 PM'".format(d)
#then simply retrieve your restricted items
filteredEmails = s.Restrict(sFilter)
</code></pre>
<p>当然,您可以通过各种条件进行限制,只需检查函数的文档即可。这样,如果您进行了限制,并且它返回了一组空的项,那么您可以在代码中处理这种情况,而不必处理异常。例如:</p>
<pre><code>#you have restricted your selection now want to check if you have anything
if filteredEmails.Count == 0:
#handle this situation however you would like
</code></pre>