在所有邮箱(帐户)上运行Outlook规则?

穆罕默德·奥尼·阿里(Mohammad Awni Ali)

我在Outlook 2016中打开了10个以上的电子邮件帐户,我有一些规则来收集所有特定主题的电子邮件到我的邮件帐户中的一个文件夹中,这里的问题是我必须选择每个邮箱,然后从中运行规则,他们有什么办法一次在所有邮箱(帐户)上运行规则吗?

穆罕默德·奥尼·阿里(Mohammad Awni Ali)

搜索互联网后,我发现以下可以在所有电子邮件帐户上运行一个或多个规则的VBA代码,如下所示:

Sub RunRulesSecondary()

Dim oStores As Outlook.Stores
Dim oStore As Outlook.Store

Dim olRules As Outlook.Rules
Dim myRule As Outlook.Rule
Dim olRuleNames() As Variant
Dim name As Variant

' Enter the names of the rules you want to run
olRuleNames = Array("Rule1")

Set oStores = Application.Session.Stores
For Each oStore In oStores
On Error Resume Next

' use the display name as it appears in the navigation pane
If oStore.DisplayName <> "[email protected]" Then

Set olRules = oStore.GetRules()

For Each name In olRuleNames()

    For Each myRule In olRules
       Debug.Print "myrule " & myRule

     If myRule.name = name Then

' inbox belonging to oStore
' need GetfolderPath functionhttp://slipstick.me/4eb2l
        myRule.Execute ShowProgress:=True, Folder:=GetFolderPath(oStore.DisplayName & "\Inbox")

' current folder
'      myRule.Execute ShowProgress:=True, Folder:=Application.ActiveExplorer.CurrentFolder

       End If
    Next
Next

End If
Next
End Sub

Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder
    Dim oFolder As Outlook.Folder
    Dim FoldersArray As Variant
    Dim i As Integer

    On Error GoTo GetFolderPath_Error
    If Left(FolderPath, 2) = "\\" Then
        FolderPath = Right(FolderPath, Len(FolderPath) - 2)
    End If
    'Convert folderpath to array
    FoldersArray = Split(FolderPath, "\")
    Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
    If Not oFolder Is Nothing Then
        For i = 1 To UBound(FoldersArray, 1)
            Dim SubFolders As Outlook.Folders
            Set SubFolders = oFolder.Folders
            Set oFolder = SubFolders.Item(FoldersArray(i))
            If oFolder Is Nothing Then
                Set GetFolderPath = Nothing
            End If
        Next
    End If
    'Return the oFolder
    Set GetFolderPath = oFolder
    Exit Function

GetFolderPath_Error:
    Set GetFolderPath = Nothing
    Exit Function
End Function

电子邮件帐户email @ domain,是我根据特定规则收集所有电子邮件的文件夹。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Outlook 规则在所有文件夹中运行

所有邮箱中的Outlook 2010搜索

从公用邮箱上的Outlook规则调用PowerShell脚本

在所有工作表上运行我的宏

jQuery-在所有项目上运行keyup函数

如何在所有模块上运行pytest?

在所有架构Postgres上运行查询

在所有推送的文件上运行预提交挂钩

在所有 udev 规则通过且设备完全初始化后运行脚本

是否可以在所有eslint规则上显示警告而不是错误?

在群集的Liferay设置中,所有模块都在所有节点上运行吗?

Outlook:禁用除主邮箱之外的所有邮箱的新邮件通知

在 EMR 上安装应用程序后,在所有节点上运行脚本

在所有地址上运行自己的用户脚本是否有风险?

在所有测试之前运行命令

在所有测试之前运行

在所有子目录上并行调用gnumake(-j),然后最后运行链接器规则(即顺序重要)

共享邮箱上的 Outlook 2007 客户端规则 - 不是自动的

imap移动后,如何自动运行运行以在收件箱上“运行所有规则”的规则

如何在所有Docker Swarm节点上运行相同的容器

在所有正在运行的X显示屏上显示通知

在所有处理器上运行 for 循环并在 Julia 中增加单个变量

在所有文件上运行都将带来什么危害?

创建后在所有 EC2 实例上运行 local-exec 配置程序

如何设置GitHub Docker CI以在所有子模块上运行

无论平台如何,如何在所有代码上运行go vet

在所有位置上给定星号(*)时,cron作业将运行多少次?

使用Fabric在所有服务器上运行命令

应用脚本:如何在所有行上运行类似的脚本?