展望 2010 VBA。尝试在我的所有文件夹中搜索标记的邮件。创建了这个:
Private Sub flagrecurse(fold As Variant)
Dim olItem As MailItem
Dim nxtfold As Folder
Dim olFoldVar As Variant
'Test for which folder is being checked
MsgBox (fold.Name)
If fold.Folders.Count > 0 Then
For Each nxtfold In fold.Folders
Set olFoldVar = nxtfold
flagrecurse olFoldVar
Next nxtfold
Else
For Each olItem In fold.Items
'Test for which item is being checked
If TypeName(olItem) = "MailItem" Then
MsgBox (olItem.Subject)
With olItem
If .FlagRequest <> "" Or .IsMarkedAsTask Then
'.TaskDueDate = Now
'Sets a reminder today, in case one wasn't set
If Not (.ReminderSet) Then
.ReminderSet = True
.ReminderTime = Now + 2 / 24
.Save
End If
End If
End With
End If
Next olItem
End If
结束子
问题是我的收件箱中有 744 个项目,它通过 8 或 9,然后给我一个“类型不匹配”。当我调试时,它会标记“下一个 olItem”,当我检查“olItem”的值时,它会解析为“无”。
我究竟做错了什么?