每小时统计收件箱中的电子邮件并保存到文本文件 [英] Count Emails In Inbox Every Hour And Save To text file

查看:96
本文介绍了每小时统计收件箱中的电子邮件并保存到文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Outlook中编写一些VBA,以每小时计数收件箱文件夹中的电子邮件(未读和已读),并在每次发生时将以下内容转储到文本文件中:

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

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?

推荐答案

做到这一点应该很简单-

示例

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



这篇关于每小时统计收件箱中的电子邮件并保存到文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆