如何在 Outlook 中統計每月發送的電子郵件數量?
有時,您可能想知道每月發送了多少封電子郵件。 本教程將介紹一個 VBA 代碼,用於統計 Outlook 中每月發送的電子郵件數量。
使用 VBA 代碼計算 Outlook 中每月發送的電子郵件數量
請應用以下 VBA 代碼來獲取每月發送的電子郵件數量,如下所示:
1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。
2。 點擊 插入 > 模塊,然後將以下代碼粘貼到 模塊 窗口。
VBA 代碼:統計每月發送的電子郵件數量:
Dim GDictionary As Object
Sub CountSentMailsByMonth()
'Updateby Extendoffice
Dim xSentFolder As Outlook.Folder
Dim xExcelApp As Excel.Application
Dim xWb As Excel.Workbook
Dim xWs As Excel.Worksheet
Dim xMonths As Variant
Dim xItemsCount As Variant
Dim xLastRow As Integer
Dim I As Integer
Dim xAccount As Account
On Error Resume Next
Set GDictionary = CreateObject("Scripting.Dictionary")
For Each xAccount In Application.Session.Accounts
If VBA.LCase$(xAccount.SmtpAddress) = VBA.LCase$("yy@addin99.com") Then 'Specify the Email Account
Set xSentFolder = xAccount.DeliveryStore.GetDefaultFolder(olFolderSentMail)
If xSentFolder.DefaultItemType = olMailItem Then
Call ProcessFolders(xSentFolder)
End If
End If
Next
Set xSentFolder = Nothing
Set xExcelApp = CreateObject("Excel.Application")
xExcelApp.Visible = True
Set xWb = xExcelApp.Workbooks.Add
Set xWs = xWb.Sheets(1)
With xWs
.Cells(1, 1) = "Month"
.Cells(1, 2) = "Count"
.Cells(1, 1).Font.Bold = True
.Cells(1, 2).Font.Bold = True
.Cells(1, 1).HorizontalAlignment = xlCenter
.Cells(1, 2).VerticalAlignment = xlCenter
End With
xMonths = GDictionary.Keys
xItemsCount = GDictionary.Items
For I = LBound(xMonths) To UBound(xMonths)
xLastRow = xWs.Range("A" & xWs.Rows.Count).End(xlUp).Row + 1
With xWs
.Cells(xLastRow, 1) = xMonths(I)
.Cells(xLastRow, 2) = xItemsCount(I)
End With
Next
xWs.Columns("A:B").AutoFit
xExcelApp.Visible = True
Set xExcelApp = Nothing
Set xWb = Nothing
Set xWs = Nothing
End Sub
Sub ProcessFolders(ByVal Fld As Outlook.Folder)
Dim I As Long
Dim xMail As Outlook.MailItem
Dim xMonth As String
Dim xSubFolder As Folder
On Error Resume Next
For I = Fld.Items.Count To 1 Step -1
If Fld.Items(I).Class = olMail Then
Set xMail = Fld.Items(I)
xMonth = Year(xMail.SentOn) & "/" & Month(xMail.SentOn)
If GDictionary.Exists(xMonth) Then
GDictionary(xMonth) = GDictionary(xMonth) + 1
Else
GDictionary.Add xMonth, 1
End If
End If
Next
If Fld.Folders.Count > 0 Then
For Each xSubFolder In Fld.Folders
Call ProcessFolders(xSubFolder)
Next
End If
End Sub
3。 仍在 Microsoft Visual Basic for Applications 窗口中,單擊 工具 > 參考在 參考項目 對話框,檢查 Microsoft Excel 16.0 對像庫 選項從 可用參考 列錶框,請參見屏幕截圖:
4。 然後點擊 OK 關閉對話框,然後按 F5 運行此代碼的關鍵。 然後,將打開一個 Excel 文件,其中顯示特定帳戶每個月發送的電子郵件計數,見截圖:
Outlook 中的 AI 郵件助理:更聰明的回覆、更清楚的溝通(一鍵魔法!) 免費
使用 Kutools for Outlook 的 AI Mail Assistant 簡化您的日常 Outlook 任務。這個強大的工具可以從您過去的電子郵件中學習,提供智慧且準確的回复,優化您的電子郵件內容,並幫助您輕鬆起草和完善訊息。

此功能支持:
- 智慧回覆:根據您過去的對話獲取精心設計的回覆——量身定制、精確且隨時可用。
- 增強內容:自動優化您的電子郵件文本,以提高清晰度和影響力。
- 輕鬆寫作:只需提供關鍵字,剩下的交給AI處理,多種寫作風格。
- 智慧擴展:透過上下文感知建議擴展您的想法。
- 摘要:立即獲得長電子郵件的簡潔概述。
- 全球覆蓋:輕鬆將您的電子郵件翻譯成任何語言。
此功能支持:
- 智慧電子郵件回复
- 優化內容
- 基於關鍵字的草稿
- 智慧內容擴充
- 電子郵件摘要
- 多國語言翻譯
最重要的是,這個功能完全 永遠!不要等待——立即下載AI郵件助理並享受!
最佳辦公生產力工具
突發新聞:Kutools for Outlook 推出免費版本!
體驗全新的 Kutools for Outlook 免費版本,具有 70 多個令人難以置信的功能,您可以永遠使用! 點擊立即下載!
🤖 Kutools人工智慧 : 使用先進的人工智慧技術輕鬆處理電子郵件,包括回覆、總結、優化、擴展、翻譯和撰寫電子郵件。
📧 電子郵件自動化: 自動回覆(適用於 POP 和 IMAP) / 安排發送電子郵件 / 發送電子郵件時按規則自動抄送/密件副本 / 自動轉送(進階規則) / 自動添加問候語 / 自動將多收件者電子郵件拆分為單獨的訊息 ...
📨 電子郵件管理: 撤回電子郵件 / 按主題和其他人阻止詐騙電子郵件 / 刪除重複的電子郵件 / 進階搜索 / 合併資料夾 ...
📁 附件專業版: 批量保存 / 批量分離 / 批量壓縮 / 自動保存 / 自動分離 / 自動壓縮 ...
🌟 介面魔法: 😊更多又漂亮又酷的表情符號 / 當重要電子郵件到來時提醒您 / 最小化 Outlook 而不是關閉 ...
👍 一鍵奇蹟: 回覆所有附件 / 反網路釣魚電子郵件 / 🕘顯示寄件者的時區 ...
👩🏼🤝👩🏻 通訊錄和行事曆: 從選定的電子郵件中大量新增聯絡人 / 將聯絡人群組拆分為各組 / 刪除生日提醒 ...
只需點擊即可立即解鎖 Kutools for Outlook。不要等待,立即下載並提高您的效率!

