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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Collecting data from outlook folders

Status
Not open for further replies.

davefish

Technical User
Jul 26, 2002
169
GB
Hi,

I'm trying to analayse the number of read emails in sub-folders of the "IN" box and like-wise the "Sent" Folder including their respective dates, in order to trend number of mails sent and recieved.

unfortunately, I have no clue in Outlook VBA on where to start with recpect to the correct objects. can anyone point me in the right direction please?

DaveFish
 
1. Go into the VBE in Outlook, and look in Help.

2. Take a look at the Object Model, this is always helpful.

3. Try searching Google.

This question comes up fairly often. I replied to pretty much the same question not that long ago. Try searching here.

faq219-2884

Gerry
My paintings and sculpture
 
Code:
Sub Analyze_Email()
   Dim ns As Outlook.NameSpace
   Dim sent As Outlook.MAPIFolder
   Dim temp As Outlook.MAPIFolder
   Dim i As Integer
   
   Set ns = GetNamespace("MAPI")

   ' Temp is a subfolder of Inbox
   Set temp = ns.GetDefaultFolder(olFolderInbox).Folders("Temp")
   
   'Set sent = ns.GetDefaultFolder(olFolderSentMail)
   
   For i = temp.Items.Count To 1 Step -1
      If temp.Items.item(i).UnRead Then
         Debug.Print "Unread :  " & temp.Items.item(i).SentOn
      Else
         Debug.Print "Read   :  " & temp.Items.item(i).SentOn
      End If
   Next
   
   'Set sent = Nothing
   
   Set temp = Nothing
   Set ns = Nothing
End Sub
 
Hi WindblowsME,

I tried this after adding a temp folder to my inbox, but it doesn't seem to work. I tried stepping through but all I get is lines in the immediate window as follows: -

Read : 28/06/2007 13:36:18
Read : 28/06/2007 14:00:38
Read : 28/06/2007 14:06:26
Read : 28/06/2007 13:36:18
Unread : 28/06/2007 14:00:38
Read : 28/06/2007 14:06:26
Read : 28/06/2007 13:36:18
Read : 28/06/2007 14:00:38
Read : 28/06/2007 14:06:26
Read : 28/06/2007 13:36:18
Unread : 28/06/2007 14:00:38
Read : 28/06/2007 14:06:26

I placed three email in the temp folder as either read or unread but again no change. Do I have to instigate anything else?

DaveFish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top