Bagaimana cara menghitung jumlah email yang dikirim per bulan di Outlook?
Terkadang, Anda mungkin ingin mengetahui berapa banyak email yang telah Anda kirim per bulan. Tutorial ini akan memperkenalkan kode VBA bagi Anda untuk menghitung jumlah email terkirim per bulan di Outlook.
Hitung jumlah email terkirim per bulan di Outlook dengan kode VBA
Silakan terapkan kode VBA di bawah ini untuk mendapatkan jumlah email terkirim setiap bulan seperti yang ditunjukkan di bawah ini:
1. Tahan ALT + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.
2. Klik Menyisipkan > Modul, dan tempel kode berikut di Modul Jendela.
Kode VBA: Hitung jumlah email yang dikirim per bulan:
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$("") 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. Masih di Microsoft Visual Basic untuk Aplikasi window, klik Tools > Referensi, Dalam Referensi-Proyek kotak dialog, periksa Perpustakaan Objek Microsoft Excel 16.0 pilihan dari Referensi yang Tersedia kotak daftar, lihat tangkapan layar:
4. Lalu klik OK untuk menutup kotak dialog, dan tekan F5 kunci untuk menjalankan kode ini. Kemudian, file Excel akan terbuka, yang menampilkan jumlah email terkirim setiap bulan untuk akun tertentu, lihat tangkapan layar:
Alat Produktivitas Kantor Terbaik
Kutools for Outlook - Lebih dari 100 Fitur Canggih untuk Meningkatkan Outlook Anda
π§ Email Otomatis: Di Luar Kantor (Tersedia untuk POP dan IMAP) / Jadwal Kirim Email / Auto CC/BCC Sesuai Aturan Saat Mengirim Email / Penerusan Otomatis (Aturan Lanjutan) / Tambah Salam Otomatis / Secara Otomatis Membagi Email Multi-Penerima menjadi Pesan Individual ...
π¨ email Management: Mengingat Email dengan Mudah / Blokir Email Penipuan berdasarkan Subjek dan Lainnya / Hapus Email Duplikat / Pencarian / Konsolidasi Folder ...
π Lampiran Pro: Penyimpanan Batch / Pelepasan Batch / Kompres Batch / Penyimpanan otomatis / Lepaskan Otomatis / Kompres Otomatis ...
π Antarmuka Ajaib: πLebih Banyak Emoji Cantik dan Keren / Tingkatkan Produktivitas Outlook Anda dengan Tampilan Tab / Minimalkan Outlook Daripada Menutup ...
π Keajaiban sekali klik: Balas Semua dengan Lampiran Masuk / Email Anti-Phishing / πTampilkan Zona Waktu Pengirim ...
π©πΌβπ€βπ©π» Kontak & Kalender: Batch Tambahkan Kontak Dari Email yang Dipilih / Bagi Grup Kontak menjadi Grup Individual / Hapus Pengingat Ulang Tahun ...
Lebih 100 Fitur Tunggu Eksplorasi Anda! Klik Di Sini untuk Menemukan Lebih Banyak.