[RESOLVED] ** MailItem in Outlook
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:
Code:
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
Problem? When there is a meeting request in the users inbox, they get a run-time error - Type Mismatch. It's occuring on the
Code:
set ca = inbox.items.getnext
because ca is a MailItem Object. My question? How do I determine what type of objects are in the Inbox?