I added this to my Outlook macros [started with code for displaying all unread messages].
After selecting Alt-F11 and ThisOutlookSession [on the left sidebar], I selected “Application” and “Startup” [which is where this code is added.]
It append to a .csv file that can be opened in Excel. This is nice if you’re attempting to get your inbox under control and want to track your progress.
Private Sub Application_Startup() On Error GoTo itfailed: ' I want to be able to catch up by reading all my unread messages Dim ns As Outlook.NameSpace Dim folder As MAPIFolder Dim item As Object Dim msg As MailItem Dim myfolder ' Open the inbox folder Set ns = Session.Application.GetNamespace("MAPI") Set folder = ns.GetDefaultFolder(olFolderInbox) myfolder = Environ$("USERPROFILE") & "my documents" myfile = "outlookunread.csv" Open myfolder & myfile For Append As 1 Print #1, Strings.Format(Now, "Short Date") + " " + Strings.Format(Now, "Long Time") + "," + CStr(folder.UnReadItemCount) + "," + CStr(folder.Items.Count) Close 1 Exit Sub itfailed: MsgBox Err.Description, vbCritical, Err.Number End Sub