Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script to count the number of mails in a given folder in Outlook
#1
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi, I have written the Script to count the number of mails in a given folder in Outlook as like this.

Code:
Set olApp = CreateObject("Outlook.Application")
Set olns = olApp.GetNameSpace("MAPI")
Set Folder = olns.GetDefaultFolder(3)
msgbox Folder.Items.Count

but my doubt is, I want to check the count of not the default folders of the Outlook, where as I need to count all the mails in my Personal folders too.

How can I change my code?

Thanks in Advance.
Reply
#2
Solved: 10 Years, 8 Months, 3 Weeks ago
use a loop to go through all the folders, and find your personal folder.
see the code below
Code:
Set olApp = CreateObject("Outlook.Application")
Set olns = olApp.GetNameSpace("MAPI")
    For icnt = 1 To olns.Folders.Count
        If UCase(ns.Folders.Item(icnt)) = "<<YOUR PERSONAL FOLDER>>" Then '
            Set Folder = olns.Folders.Item(icnt)
            Exit For
        End If
    Next
msgbox Folder.Items.Count

Reply
#3
Solved: 10 Years, 8 Months, 3 Weeks ago
Thanks Saketh, it is working now
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Extracting Email Body from Outlook waseem.khan.91 0 1,879 03-04-2019, 02:53 PM
Last Post: waseem.khan.91
  Extracting Email Body from Outlook waseem.khan.91 0 1,022 03-01-2019, 02:51 PM
Last Post: waseem.khan.91
  VB Script:number of times a character appears in a string with position Jyobtech 1 11,700 08-07-2013, 01:03 PM
Last Post: anil2u
  Creating a folder from within a reusable action. sd3 2 2,984 06-18-2013, 03:20 PM
Last Post: learnQtptips
  to count the number of used rows in a particular column sujaravi123 3 10,909 06-12-2013, 03:17 PM
Last Post: sujaravi123

Forum Jump:


Users browsing this thread: 1 Guest(s)