Ga naar hoofdinhoud

Hoe tel je het aantal verzonden e-mails per maand in Outlook?

Soms wil je misschien weten hoeveel e-mails je per maand hebt verzonden. Deze zelfstudie introduceert een VBA-code waarmee u het aantal verzonden e-mails per maand in Outlook kunt tellen.


Tel het aantal verzonden e-mails per maand in Outlook met VBA-code

Pas de onderstaande VBA-code toe om het aantal verzonden e-mails per maand te ontvangen, zoals hieronder weergegeven:

1. Houd de ALT + F11 toetsen om de te openen Microsoft Visual Basic voor toepassingen venster.

2. Klikken Invoegen > Moduleen plak de volgende code in het Module Venster.

VBA-code: tel het aantal verzonden e-mails per maand:

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
Note: Wijzig in de code het e-mailaccount "” naar je eigen.

3. Nog steeds in de Microsoft Visual Basic voor toepassingen venster klikt Tools > Referenties, in de Referenties-Project dialoogvenster, vink aan Microsoft Excel 16.0-objectbibliotheek optie van de Beschikbare referenties keuzelijst, zie screenshot:

4. Dan klikken OK om het dialoogvenster te sluiten en druk op F5 sleutel om deze code uit te voeren. Vervolgens wordt een Excel-bestand geopend, waarin het aantal verzonden e-mails van elke maand voor het specifieke account wordt weergegeven, zie screenshot:


Beste Office-productiviteitstools

Kutools for Outlook - Meer dan 100 krachtige functies om uw Outlook een boost te geven

🤖 AI Mail-assistent: Directe professionele e-mails met AI-magie: met één klik geniale antwoorden, perfecte toon, meertalige beheersing. Transformeer e-mailen moeiteloos! ...

???? Email Automation: Niet aanwezig (beschikbaar voor POP en IMAP)  /  Plan het verzenden van e-mails  /  Automatische CC/BCC volgens regels bij het verzenden van e-mail  /  Automatisch doorsturen (geavanceerde regels)   /  Begroeting automatisch toevoegen   /  Splits e-mails van meerdere ontvangers automatisch op in individuele berichten ...

📨 email management: Gemakkelijk e-mails herinneren  /  Blokkeer zwendel-e-mails van onderwerpen en anderen  /  Verwijder dubbele e-mails  /  Uitgebreid Zoeken  /  Consolideer mappen ...

📁 Bijlagen ProBatch opslaan  /  Batch losmaken  /  Batchcompressie  /  Automatisch opslaan   /  Automatisch loskoppelen  /  Automatisch comprimeren ...

???? Interface-magie: 😊Meer mooie en coole emoji's   /  Verhoog uw Outlook-productiviteit met weergaven met tabbladen  /  Minimaliseer Outlook in plaats van te sluiten ...

???? Wonderen met één klik: Beantwoord iedereen met inkomende bijlagen  /   Antiphishing-e-mails  /  🕘Toon de tijdzone van de afzender ...

👩🏼‍🤝‍👩🏻 Contacten en agenda: Batchcontacten toevoegen uit geselecteerde e-mails  /  Splits een contactgroep in individuele groepen  /  Verwijder verjaardagsherinneringen ...

Over 100 Eigenschappen Wacht op je verkenning! Klik hier om meer te ontdekken.

 

 

Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations