Results 1 to 20 of 22

Thread: Outlook - count number of emails in Sent Items folder and spit out results in Excel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    I am not sure where Excel comes into this but the following should point the way. Change your company domain as appropriate. If there are many items in the sent folder this could take a while to run

    Sub CountSent()
        Dim olFolder As Folder
        Dim olItem As Object
        Dim lngCount As Long: lngCount = 0
        Set olFolder = Session.GetDefaultFolder(olFolderSentMail)
        For Each olItem In olFolder.items
            If TypeName(olItem) = "MailItem" Then
                If Not olItem.Recipients(1).Address Like "*@yourcompanydomain.com" Then
                    lngCount = lngCount + 1
                End If
            End If
            DoEvents
        Next olItem
        MsgBox lngCount & " items sent"
        lbl_Exit:
        Set olFolder = Nothing
        Set olItem = Nothing
        Exit Sub
    End Sub
    Last edited by Aussiebear; 02-17-2025 at 11:05 PM.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

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