Understanding Folder names in Outlook VBA RRS feed

  • Question

  • This is a script for a Rule in Outlook designed to move messages to "TestFilter" with "canadian" as part of the sender's name.

    I added trace messages to check progress. The script apparently stops before echoing the name of the target folder. What am I doing wrong?

    Sub CheckSpam(Item As Outlook.MailItem)

        Dim Inbox As Outlook.Folder
        Dim TargetFolder As Outlook.Folder

        Set Inbox = Session.GetDefaultFolder(olFolderInbox)
        MsgBox ("Got " + Inbox)

        Set TargetFolder = Inbox.Folders("TestFilter")
        MsgBox ("Got " + TargetFolder)                                        <---------------------DOES NOT ECHO NAME OF TARGETFOLDER

        If InStr(LCase(Item.SenderName), "canadian") Then
           Item.Move TargetFilter
        End If
        MsgBox ("Done")

    End Sub

    Saturday, November 14, 2020 9:43 PM