I have the following code that will move all messages from the Inbox to a folder the user selects from the "Select Folder" dialog box:
Problem? When there is a meeting request in the users inbox, they get a run-time error - Type Mismatch. It's occuring on theCode:Sub LAC_MoveMail() Dim ns As NameSpace Dim Inbox As MAPIFolder Dim Item As Object Dim ca As MailItem Dim myNewFolder As MAPIFolder Set ns = GetNamespace("MAPI") Set Inbox = ns.GetDefaultFolder(olFolderInbox) Set myNewFolder = ns.PickFolder Set ca = Inbox.Items.GetFirst While TypeName(ca) <> "Nothing" ca.Move myNewFolder Set ca = Inbox.Items.GetNext Wend Set ca = Inbox.Items.GetLast ca.Move myNewFolder End Sub
because ca is a MailItem Object. My question? How do I determine what type of objects are in the Inbox?Code:set ca = inbox.items.getnext




Reply With Quote