Reputation: 873
I'm trying to write some VBA in Outlook to count emails in the inbox folder (unread and read) every hour and to dump something like the below to a text file each time that happens:
28/02/2018 01:00 - 1,320
I've seen various code snippets, but I'm not sure how to achieve this. Could someone help please?
Upvotes: 0
Views: 487
Reputation: 12499
Should be simple to do that-
Example
Option Explicit
Public Sub example()
Dim Items As Outlook.Items
Set Items = Application.Session.GetDefaultFolder( _
olFolderInbox).Items
Debug.Print Now() & " - " & Items.Count
Dim FSO As New FileSystemObject
Dim TS As TextStream
Set TS = FSO.OpenTextFile("C:\Temp\Emails_Count.txt", ForAppending, True)
TS.Write Now() & " - " & Items.Count
TS.Close
End Sub
Upvotes: 1