Type Mismatch in mailitem loop
Outlook 2010 VBA. Trying to search for flagged messages in all my folders. Created this: 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