vbaoutlooktype-mismatch

In MS Outlook VBA, why a type mismatch on this call to MailItem.Move?


The method MailItem.Move has the syntax:

<MailItem>.Move(<Folder>)

The following display image shows the code I'm running, two watches, and the error they give:

enter image description here

When the error occurs and I click "Debug", the code comes up with yellow highlighting on the line:

oMailItem.Move (oDestFolder)

The watches show that oMailItem is of the correct type MailItem and oDestFolder is of the correct type Folder. The watch window also shows the names of those objects, indicating that they exist.

So, why the type mismatch?


Solution

  • Try to get rid of ():

    oMailItem.Move oDestFolder