Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Brugge, Belgium
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Number of items in the inbox of outlook (MS Access 2007)

    one part of my ms access program concernes importing emails from outlook.
    With the following code (partly) :

    Dim olApp As Outlook.Application
    Dim olNs As Namespace
    Dim Fldr As MAPIFolder
    Dim olMi As mailitem
    Dim olAtt As Outlook.attachment
    Dim i As Long
    Dim Aantal As Integer

    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    If Err = 429 Then
    Set olApp = CreateObject("Outlook.Application")
    End If
    On Error GoTo ErrorHandler
    Set olNs = olApp.GetNamespace("MAPI")
    Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
    If i = Nz(Fldr.Items.Count ) =0 then
    Msgbox " No items in inbox"
    else
    For i = Fldr.Items.Count To 1 Step -1
    .....

    I get as result "no items in inbox. " However there are more than 20 items in the inbox.
    What's wrong with this code?
    Is it possible tocount the number of items that are already read and how many are not been read ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Number of items in the inbox of outlook (MS Access 2007)

    The statement

    If i = Nz(Fldr.Items.Count ) =0 then

    is incorrect. When you execute it, i = 0, and Count is >0, so i = Nz(Fldr.Items.Count ) evaluates to False = 0. And 0 = 0 is True.

    Also, there is no reason to use Nz here, for Fldr.Items.Count can't be Null (it can be zero, but not Null).

    So change the line to

    If Fldr.Items.Count = 0 Then

  3. #3
    2 Star Lounger
    Join Date
    Jan 2002
    Location
    Brugge, Belgium
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Number of items in the inbox of outlook (MS Access 2007)

    Thank you very much

Posting Permissions

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