Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count e-mails

Status
Not open for further replies.

tenbellies

Programmer
Dec 20, 2002
17
GB
Is there a way of counting how many e-mails comes into an inbox. We use Outlook 2000, it is a shared mailbox which anyone can access.
 
I used this coding in an excel book to find out how many emails I had in each of my subfolders in the INbox.

Sub CountEmails()
Application.ScreenUpdating = False
Dim objApp As Outlook.Application
Dim ns As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
Dim fldInbox As Outlook.MAPIFolder
Dim mi As Outlook.MailItem
Dim unreadm As Integer, readm As Integer
Set objApp = GetObject(, "Outlook.Application")
Set ns = objApp.GetNamespace("MAPI")
mydate = Date
Set fldInbox = ns.GetDefaultFolder(6)
For Each fld In fldInbox.Folders
unreadm = 0: readm = 0
For Each mi In fld.Items
If mi.UnRead Then
unreadm = unreadm + 1
Else
readm = readm + 1
End If
Next
Sheets("Email Data").Select
Range("a1").End(xlDown).Offset(1, 0).Select
ActiveCell = fld.Name
ActiveCell.Offset(0, 1).Value = "="
ActiveCell.Offset(0, 2).Activate
ActiveCell = unreadm
ActiveCell.Offset(0, 1).Activate
ActiveCell = readm
Next
End Sub

Thanks Rob.[yoda]
 
Thanks for the tip but i need it to do a count as they arrive, as when each e-mail is delt with it gets deleted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top