仅当任务处于活动状态时才处理Outlook任务

时间:2017-10-24 20:28:29

标签: outlook outlook-vba

我有一个宏,使用“For Each”处理默认文件夹中的所有现有任务,如下面的代码所示。但问题是,这也处理已经处于非活动状态(完成)的任务。在我的情况下,我有10,000个任务,这些过程是不经意的。任何想法如何改进做“为每个,这是积极的......”?

Set olkApp = CreateObject("Outlook.Application")  
Set olkNS = olkApp.GetNamespace("MAPI")
olkNS.Logon "Outlook"    
Set olkTaskFolder = olkNS.GetDefaultFolder(6)  
For Each objItem In olkTaskFolder.Items  

类似于 Outlook Script to process task updates

1 个答案:

答案 0 :(得分:1)

Set olkTaskFolder = olkNS.GetDefaultFolder(6)  
set objItems = olkTaskFolder.Items.Restrict("[Complete] = 'false' ")
For Each objItem In objItems 

你可以使用Restrict来完成任务:

df.loc[(df['work'] == 1) & df['hour'].isin([0, 1, 2, 3, 4, 5, 6]),['hindex']] = 1
df.loc[(df['work'] == 1) & df['hour'].isin([7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), ['hindex']] = 2
df.loc[(df['work'] == 1) & df['hour'].isin([17, 18, 19, 20, 21, 22, 23]), ['hindex']] = 3

df.loc[(df['work'] == 0) & df['hour'].isin([0, 1, 2, 3, 4, 5, 6]), ['hindex']] = 1
df.loc[(df['work'] == 0) & df['hour'].isin([7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), ['hindex']] = 2
df.loc[(df['work'] == 0) & df['hour'].isin([17, 18, 19, 20, 21, 22, 23]), ['hindex']] = 3