Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to classify the emails by month in Outlook?

Author Xiaoyang Last modified

If there are lots of emails in your Inbox, to make the mailbox look neat and well-organized, you can store or archive them into different folders based on the specific month of the emails’ received time as below screenshot shown. Normally, you can create the folders manually and then move them one by one. Obviously, this approach will be time-consuming and troublesome. In this article, I will talk about a VBA code for solving this task quickly and easily.

classify-emails-by-month/doc-classify-by-month-1


Classify the emails based on month with VBA code

To move the emails to different folders based on month, please apply the below VBA code:

1. Click to select the Inbox folder that you want to classify the emails.

2. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

3. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Classify the emails based on month

Sub ClassifyEmailsbyMonth()
'Updateby ExtendOffice
Dim xCurFolder As Folder
Dim xMoveFolder As Folder
Dim xMail As MailItem
Dim I As Long
Dim xYear As String, xMonth As String
On Error Resume Next
Set xCurFolder = Application.ActiveExplorer.CurrentFolder
For I = xCurFolder.Items.Count To 1 Step -1
  DoEvents
  If xCurFolder.Items.Item(I).Class = olMail Then
    Set xMail = xCurFolder.Items.Item(I)
    xYear = Year(xMail.ReceivedTime)
    xMonth = Month(xMail.ReceivedTime)
    Set xMoveFolder = Nothing
    Set xMoveFolder = xCurFolder.Folders(xYear & "." & xMonth)
    If xMoveFolder Is Nothing Then
      Set xMoveFolder = xCurFolder.Folders.Add(xYear & "." & xMonth)
    End If
    xMail.Move xMoveFolder
  End If
Next
Set xMoveFolder = Nothing
Set xCurFolder = Nothing
End Sub

classify-emails-by-month/doc-classify-by-month-2

4. Then, press F5 key to execute this code, and all the emails in the selected Inbox folder are classified by specific month of the emails’ received time, see screenshot:

classify-emails-by-month/doc-classify-by-month-1

AI Mail Assistant in Outlook: Smarter Replies, Clearer Communication (one-click magic!) FREE

Streamline your daily Outlook tasks with the AI Mail Assistant from Kutools for Outlook. This powerful tool learns from your past emails to offer intelligent and accurate responses, optimize your email content, and help you draft and refine messages effortlessly.
doc ai email handle

This feature supports:

  • Smart Replies: Get responses crafted from your past conversations—tailored, precise, and ready to go.
  • Enhanced Content: Automatically refine your email text for clarity and impact.
  • Effortless Composition: Just provide keywords, and let AI handle the rest, with multiple writing styles.
  • Intelligent Extensions: Expand your thoughts with context-aware suggestions.
  • Summarization: Get concise overviews of long emails instantly.
  • Global Reach: Translate your emails into any language with ease.

This feature supports:

  • Smart email replies
  • Optimized content
  • Keyword-based drafts
  • Intelligent content extension
  • Email summarization
  • Multi-language translation

Best of all, this feature is completely free forever! Don’t wait—download AI Mail Assistant now and enjoy!


Best Office Productivity Tools

Breaking News: Kutools for Outlook Launches Free Version!

Experience the all-new Kutools for Outlook with 100+ incredible features! Click to download now!

🤖 Kutools AI : Uses advanced AI technology to handle emails effortlessly, including replying, summarizing, optimizing, extending, translating, and composing emails.

📧 Email Automation: Auto Reply (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

📨 Email Management: Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

📁 Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

🌟 Interface Magic: 😊More Pretty and Cool Emojis   /  Remind you when important emails come  /  Minimize Outlook Instead of Closing ...

👍 One-click Wonders: Reply All with Attachments  /   Anti-Phishing Emails  /  🕘Show Sender's Time Zone ...

👩🏼‍🤝‍👩🏻 Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Instantly unlock Kutools for Outlook with a single click. Don't wait, download now and boost your efficiency!

kutools for outlook features1 kutools for outlook features2

🚀 One-Click Download — Get All Office Add-ins

Strongly Recommended: Kutools for Office (5-in-1)

One click to download five installers at once — Kutools for Excel, Outlook, Word, PowerPoint and Office Tab Pro. Click to download now!

  • One-click convenience: Download all five setup packages in a single action.
  • 🚀 Ready for any Office task: Install the add-ins you need, when you need them.
  • 🧰 Included: Kutools for Excel / Kutools for Outlook / Kutools for Word / Office Tab Pro / Kutools for PowerPoint