err 13 type mismatch, for each mail - appointment request


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA RSS
Next:  getting image attachments in OUTLOOK 2007  
Author Message
izyrider



Joined: Dec 17, 2007
Posts: 1



PostPosted: Mon Dec 17, 2007 12:37 pm    Post subject: err 13 type mismatch, for each mail - appointment request

in the below code i am forced to trap/resume err 13 or the code falls over when the loop hits the first (oldest) appointment request.

this seems inelegant: is there a better way?

TIA, izyrider

Code:

Public Sub cmCategorise()

    On Error GoTo err_cmCategorise

    Dim obMsg As Outlook.MailItem
    Dim obNameSpace As NameSpace
    Dim obInbox As Outlook.MAPIFolder
    Dim i As Integer

    Set obNameSpace = Application.GetNamespace("MAPI")
    Set obInbox = obNameSpace.GetDefaultFolder(olFolderInbox)
   
   'is it working - just count for the moment
    For Each obMsg In obInbox.Items
        i = i + 1
    Next
    MsgBox "There are " & i & " items in the inbox"
   
exit_cmCategorise:
    On Error Resume Next
    Set obInbox = Nothing
    Set obNameSpace = Nothing
    Exit Sub

err_cmCategorise:
    Select Case Err.Number
        Case 13
            Resume
        Case Else
            MsgBox Err.Number & ": " & Err.Description, vbExclamation, "ERROR in cmCategorise"
            Resume exit_cmCategorise
    End Select

End Sub
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum