Consulting

Results 1 to 5 of 5

Thread: Perform Count of Incoming Emails?

  1. #1
    VBAX Newbie Nox's Avatar
    Joined
    Nov 2008
    Location
    Houston, TX
    Posts
    3

    Perform Count of Incoming Emails?

    Re: Outlook 2003

    I've been asked to keep a record of how many emails are received in a week, I know I can do this manually (pen and paper, old school style), but there has got to be a way to some how record the number of emails received per week (per day would be even better). Is this possible?

    Perhaps have the count tracked in Notepad or Excel, whatever.. All ideas welcome.

    Thank you in advance for all assistance,
    -Nox

  2. #2
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    Try this.

    Sub X()
    
        Dim objOLApp As Object
        Dim objMAPI As Object
        Dim objOLFolder As Object
        Dim objOLMail As Object
        Dim datStart As Date
        Dim datEnd As Date
        Dim lngCount As Long
        
        Const olFolderInbox = 6
        
        Set objOLApp = GetObject(, "Outlook.Application")
        Set objMAPI = objOLApp.GetNamespace("MAPI")
        
        datStart = "1/Nov/2008"
        datEnd = "21/Nov/2008"
        
        Set objOLFolder = objMAPI.GetDefaultFolder(olFolderInbox)
        For Each objOLMail In objOLFolder.Items
            If objOLMail.receivedtime >= datStart And objOLMail.receivedtime <= datEnd Then
                Debug.Print objOLMail.receivedtime, objOLMail.Subject
                lngCount = lngCount + 1
            End If
        Next
        MsgBox lngCount & " messages between " & datStart & " and " & datEnd
        
        Set objOLFolder = Nothing
        Set objMAPI = Nothing
        Set objOLApp = Nothing
        
    End Sub
    Cheers
    Andy

  3. #3
    VBAX Newbie Nox's Avatar
    Joined
    Nov 2008
    Location
    Houston, TX
    Posts
    3
    Great, I'll give that shot.

    Now, if this isn't a count that is going to be in the default user inbox, how do I get it to run in a group email box?

    Thank you!

  4. #4
    VBAX Newbie Nox's Avatar
    Joined
    Nov 2008
    Location
    Houston, TX
    Posts
    3

    Lightbulb

    Okay, actually, I don't need to do that (above).

    How can I modify that code to count things from a specific person/email address?

  5. #5
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    You need to check other properties of the mail item such as Subject, Sender.

    If you include a reference the Outlook object library, via Tools > References, you can use the object browser to see properties of outlook items.
    Cheers
    Andy

Posting Permissions

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