Results 1 to 2 of 2

Thread: [RESOLVED] ** MailItem in Outlook

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2002
    Posts
    46

    [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?
    Last edited by charlie79; Apr 16th, 2004 at 07:58 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width