Outlook模板规则可在目录之间对邮件进行排序 [英] Outlook template rule to sort mails among directories

查看:298
本文介绍了Outlook模板规则可在目录之间对邮件进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有为不同项目创建的文件夹(例如Proj1,Proj2,Proj3等). 在部门中通常会发送有关特定项目的电子邮件,并在主题中注明其名称(例如"Proj1:项目已完成!").

I have folders created for different projects (e.g. Proj1, Proj2, Proj3, ...). It is general convention in the department to sent emails concerning specific project with its name in the subject (e.g. "Proj1: project finished!").

我知道我可以为每个项目创建规则,以将包含其名称的邮件移动到项目文件夹中.但是,我将需要创建与我拥有的文件夹数量一样多的规则-因此它不是很方便,也不理想.

I know that I can create rules for every project to move mails that contain its name to the project folder. However, I would need to create as many rules as the number of folders I have - so its not very convenient and optimal.

是否有任何方法可以创建一个规则(单个规则)(可能使用VBA代码),该规则将包含所有文件夹名称的列表,从邮件的子主题中的列表中搜索任何名称,然后自动将邮件移动到相应的文件夹中文件夹?

Is there any way to create a rule (a single rule) (possibly, with VBA code) that will contain list of all folder names, search for any name from the list among mails' subjucts and automatically move mail to the corresponding folder?

推荐答案

要完全实现您想要的功能,可以使用以下宏:

In order to achieve exactly what you want you can use this macro:

Sub RulesForFolders(m As MailItem)
Dim fldr As Outlook.Folder
For Each fldr In GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders
    If m.Subject Like "*" & fldr.Name & "*" Then m.Move fldr
Next
Set fldr = Nothing
End Sub

如果您将以下行添加到ThisOutlookSession模块中,则可以通过收到新电子邮件来触发此宏:

This macro can be triggered by arrival of a new email if you add to ThisOutlookSession module these lines:

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim o As Object
Set o = Application.Session.GetItemFromID(EntryIDCollection)
If TypeName(o) = "MailItem" Then RulesForFolders o
Set o = Nothing
End Sub

不过,我建议您摆脱将邮件移至的文件夹.相反,您可以将所有邮件保留在收件箱"中,并使用搜索"文件夹将邮件按所需顺序进行分组.这样,您可以快速搜索所有收件箱并对其进行排序以及单独的搜索文件夹.您也可以在不同的文件夹中包含相同的消息,而不进行重复.如果您决定这样做,则您的宏将需要分配类别,而不是移动消息:

Though, I would recommend you get rid of the folders where you move your messages to. Instead, you can use keep all you messages in Inbox and use Search folders to group them in whatever order you want. This way you can quickly search through all your inbox and sort it as well as separate search folders. You can also have the same message in different folders not duplicating it. If you decide to do so, your macro will need to assign categories instead of moving messages:

Sub RulesForFolders(m As MailItem)
Dim fldr As Outlook.Folder, str As Outlook.Store
For Each str In Application.Session.Stores
    For Each fldr In str.GetSearchFolders
        If m.Subject Like "*" & fldr.Name & "*" Then
            m.Categories = m.Categories & "," & fldr.Name
            m.Save
        End If
    Next
Next
Set fldr = Nothing
Set str = Nothing
End Sub

这篇关于Outlook模板规则可在目录之间对邮件进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆