2017-10-13 99 views
0

我遇到了一个脚本问题。 脚本自动化我们的共享邮箱(Outlook)。它会自动将邮件分配给正确的人。VBScript - 检查mailItem是否仍然可行

每次脚本运行时,它会循环该文件夹中的所有邮件并检查它是否具有类别。如果不是,则将其分配给正确的用户。 问题是,当无类邮件被拖动到另一个文件夹中运行该脚本时,它试图执行mail.Categories

Line: 222 Error: Could not complete the operation due to error 8004010f.

时抛出一个错误有没有一种方法来检查的MailItem仍然是可行的?

我试过使用IsEmpty,但msgbox不会触发。

Set outlook = CreateObject("Outlook.Application") 
Set namespace = outlook.GetNameSpace("MAPI") 

Set Account = namespace.Folders("accountName") 
Set Inbox = argentaAccount.Folders("Inbox") 

For Each mail in Inbox.Items 

    If IsEmpty(mail) Then 
     MsgBox("test") 
    End If 

    'check if item has a category' 
    If mail.Categories <> "" Then 
     'has a category' 
    Else 
     'Execute mailhandling code' 
    End If 
Next 

如果有人有任何解决方案,我会永远感激。

回答

0

利用该线为线索:

If IsEmpty(mail) Then 

VBScript的可能工作相同VBA其中对于像每个作品:

For i = 1 to Inbox.Items.Count 

当项目1被移动(或删除),第2项移动到位置1.在下一个循环中,处理位置2和项目3。每一秒都会被跳过。在循环的后半部分没有任何处理。与此在VBA处理的

的一种方式是到步骤以相反的顺序:

For i = Inbox.Items.Count to 1 step -1 
    Set mail = Inbox.Items(i) 
    If mail.Categories <> "" 
相关问题