Count Emails In Inbox Every Hour And Save To text file

醉酒当歌 提交于 2020-01-06 06:43:08

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/49070893/count-emails-in-inbox-every-hour-and-save-to-text-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!