跳到主要内容

如何在Outlook中按月对电子邮件进行分组和排序?

作者:凯莉 最后修改时间:2020-05-08

默认情况下,电子邮件在Outlook的“收件箱”中按接收日期排序。 但是,没有命令按接收月份对所有电子邮件进行排序或分组。 在这里,我将介绍一种在Outlook中按月对所有电子邮件进行分组和排序的方法。

使用VBA代码在Outlook中按月对电子邮件进行分组或排序


使用VBA代码在Outlook中按月对电子邮件进行分组或排序

此方法将指导您创建一个名为“月”的新列,然后应用VBA宏将收到的月提取到新列中,然后您可以在Outlook中按“月”列对所有电子邮件进行排序或分组。

1.  打开一个邮件文件夹,您将在其中按月对电子邮件进行排序或分组,然后单击 查看设置 上的按钮 首页 选项卡在Outlook 2010和更高版本中。

doc按第1个月排序电子邮件

请注意: 在Outlook 2007中,您可以单击 首页 > 当前视图 > 自定义当前视图.

2。 即将来临 高级视图设置/自定义视图 对话框中,单击 按钮(或 字段 按钮)。

doc按第2个月排序电子邮件

3。 在里面 显示列/字段 对话框中,单击 新的列 按钮(或 新场 按钮)以打开“新建列/字段”对话框,键入 ,在 名称 盒子,保持 文本 同时选择 Type 盒子和 格式 框,然后单击 OK 按钮。 参见下面的截图:

doc按第3个月排序电子邮件

4.  现在您回到 显示列/字段 对话框,单击以选择 中的项目 显示这些列 (或 字段) 按此顺序 框,然后将其移到 收到 通过点击 提前 按钮,最后点击 OK 按钮。

doc按第4个月排序电子邮件

5。 点击 OK 按钮关闭 高级视图设置/自定义视图 对话框。

6。 选择打开的文件夹中的所有电子邮件,选择任何电子邮件,然后按 按Ctrl + A 键同时。

备注:如果 阅读面板 正在开启,请点击 首页 > 阅读面板 > 关闭.

7。 打开 Microsoft Visual Basic应用程序 按下 其他 + F11 同时键入,然后单击 插页 > 模块.

8。 将以下VBA宏粘贴到模块中:

VBA:按月对电子邮件进行排序或分组

Sub ListSelectionMonth()
	Dim aObj As Object
	Dim oProp As Outlook.UserProperty
	Dim sMonth
	
	On Error Resume Next
	
	For Each aObj In Application.ActiveExplorer.Selection
		Set oMail = aObj
		
		sMonth = Month(oMail.ReceivedTime)
		Set oProp = oMail.UserProperties.Add("Month", olText, True)
		oProp.Value = sMonth
		oMail.Save
		
		Err.Clear
	Next
	
End Sub

9。 按 F5 运行此VBA宏的关键。

10。 现在,每个电子邮件的接收月份都提取到以下内容中 柱。 要按月在此打开的文件夹中对所有电子邮件进行排序,只需单击 。 看截图:

doc按第5个月排序电子邮件

备注:要按月在此打开文件夹中对所有电子邮件进行分组,请右键单击的列标题 ,然后选择 按此字段分组 从右键单击菜单中。 看截图:

doc按第6个月排序电子邮件


最佳办公生产力工具

最新消息:Kutools for Outlook 发布 免费版本!

体验全新的 Kutools for Outlook 免费版本拥有 70 多项令人难以置信的功能,您可以永久使用! 点击立即下载!

🤖 Kutools人工智能 : 具有人工智能魔力的即时专业电子邮件——一键天才回复、完美语气、多语言掌握。轻松改变电子邮件! ...

📧 电子邮件自动化: 自动回复(适用于 POP 和 IMAP)  /  安排发送电子邮件  /  发送电子邮件时按规则自动抄送/密件抄送  /  自动转发(高级规则)   /  自动添加问候语   /  自动将多收件人电子邮件拆分为单独的消息 ...

📨 电子邮件管理: 撤回电子邮件  /  按主题和其他人阻止诈骗电子邮件  /  删除重复的电子邮件  /  高级搜索  /  合并文件夹 ...

📁 附件专业版批量保存  /  批量分离  /  批量压缩  /  自动保存   /  自动分离  /  自动压缩 ...

🌟 界面魔法: 😊更多又漂亮又酷的表情符号   /  收到重要邮件时提醒您  /  最小化 Outlook 而不是关闭 ...

👍 一键奇迹: 使用传入附件回复全部  /   反网络钓鱼电子邮件  /  🕘显示发件人的时区 ...

👩🏼‍🤝‍👩🏻 通讯录和日历: 从选定的电子邮件中批量添加联系人  /  将联系人组拆分为各个组  /  删除生日提醒 ...

只需单击一下即可立即解锁 Kutools for Outlook -永久免费. 别等了, 立即下载并提高您的效率!

kutools for outlook 功能1 kutools for outlook 功能2
 

 

 

Comments (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
If you want to automate further, assign a button to the macro.
There are 2 issues with the macro.
1. You have to select all.
2. The months don't sort correctly because there is no leading 0 for single digits.

This amended code addresses those issues.

Sub ListSelectionMonth()
Dim aObj As Object
Dim oProp As Outlook.UserProperty
Dim sMonth

' Select All Items in current folder
Application.ActiveExplorer.SelectAllItems

On Error Resume Next

For Each aObj In Application.ActiveExplorer.Selection
Set oMail = aObj

sMonth = Month(oMail.ReceivedTime)
'ADD a leading 0 for single digits
If sMonth < 10 Then sMonth = "0" & sMonth
Set oProp = oMail.UserProperties.Add("Month", olText, True)
oProp.Value = sMonth
oMail.Save

Err.Clear
Next

End Sub
This comment was minimized by the moderator on the site
I have Outlook 2007 and have try that VBA. First I did have the problem that only 1 E-Mail of all get the month show.
I needed to mark all E-Mails first and then push in VBA F5 to show in all E-Mails the month.

a bad part of that code is that all month (1, 2, 3, 4, 5, 6, 7, 8, 9) get grouped on the wrong position in front of 10, 11, 12
is there any additional VBA sequence what add to the first 9 Month a 0? ergo 01, 02, 03 etc?

as I have several years in some folders it make sense to group those E-Mails first by year and after that by Month.
This comment was minimized by the moderator on the site
Strange.
Made a restart. Now it works.Sorry for bothering.
Thx again :) <3
This comment was minimized by the moderator on the site
Sorry. Didn't saw that the page is origin in english. #emabarrased
Google translate is getting better. :D
Hello from Hamburg,
great stuff. Thanks for this. :)
Only a small problem.
I had first adapted the code so that it puts the year and month together for me.

Sub ListSelectionYearMonth()
Dim aObj As Object
Dim oProp As Outlook.UserProperty
Dim oMail As Object
Dim sMonth
Dim sYear
Dim sYearMonth

On Error Resume Next

For Each aObj In Application.ActiveExplorer.Selection
Set oMail = aObj

sMonth = Month(oMail.ReceivedTime)
sYear = Year(oMail.ReceivedTime)

If sMonth < 10 Then
sMonth = 0 & sMonth
Else
sMonth = sMonth
End If

sYearMonth = sYear & "/" & sMonth
Set oProp = oMail.UserProperties.Add("YearMonth", olText, True)
oProp.Value = sYearMonth
oMail.Save

Err.Clear
Next

End Sub

This worked wonderfully.
Now I noticed in a folder that a grouping first by year and then by month increases the clarity.
I used the original code.
However, the column there remains empty.

Sub ListSelectionMonth()
Dim aObj As Object
Dim oProp As Outlook.UserProperty
Dim oMail As Object
Dim sMonth

On Error Resume Next

For Each aObj In Application.ActiveExplorer.Selection
Set oMail = aObj

sMonth = Month(oMail.ReceivedTime)

If sMonth < 10 Then
sMonth = 0 & sMonth
Else
sMonth = sMonth
End If

Set oProp = oMail.UserProperties.Add("Month", olText, True)
oProp.Value = sMonth
oMail.Save

Err.Clear
Next

End Sub

I'm a bit perplexed at the moment.

Glad about any advice

VG
Armin


Translated with http://www.DeepL.com/Translator (free version)
This comment was minimized by the moderator on the site
Hallo aus Hamburg,super Sache. Danke dafür. :)Kleines Problem nur.Ich hatte zuerst den Code so angepasst das er mir Jahr und Monat zusammensetzt.
Sub ListSelectionYearMonth()
Dim aObj As Object
Dim oProp As Outlook.UserProperty
Dim oMail As Object
Dim sMonth
Dim sYear
Dim sYearMonth

On Error Resume Next

For Each aObj In Application.ActiveExplorer.Selection
Set oMail = aObj

sMonth = Month(oMail.ReceivedTime)
sYear = Year(oMail.ReceivedTime)

If sMonth < 10 Then
sMonth = 0 & sMonth
Else
sMonth = sMonth
End If

sYearMonth = sYear & "/" & sMonth
Set oProp = oMail.UserProperties.Add("JahrMonat", olText, True)
oProp.Value = sYearMonth
oMail.Save

Err.Clear
Next

End Sub

Hat wunderbar geklappt.Nun ist mir in einem Ordner aufgefallen das eine Gruppierung zuersnach Jahr und dann nach Monat die Übersichtlichkeit noch erhöht.Habe als den ursprünglichen Code genommen.Dort bleibt dann allerdings die Spalte leer.
Sub ListSelectionMonth()
Dim aObj As Object
Dim oProp As Outlook.UserProperty
Dim oMail As Object
Dim sMonth

On Error Resume Next

For Each aObj In Application.ActiveExplorer.Selection
Set oMail = aObj

sMonth = Month(oMail.ReceivedTime)

If sMonth < 10 Then
sMonth = 0 & sMonth
Else
sMonth = sMonth
End If

Set oProp = oMail.UserProperties.Add("Monat", olText, True)
oProp.Value = sMonth
oMail.Save

Err.Clear
Next

End Sub

Macht mich grad etwas ratlos.
Freue mich über jeden Rat
VGArmin
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations