![将 Outlook 2003 规则导出为文本](https://linux22.com/image/1227012/%E5%B0%86%20Outlook%202003%20%E8%A7%84%E5%88%99%E5%AF%BC%E5%87%BA%E4%B8%BA%E6%96%87%E6%9C%AC.png)
我遇到了 Outlook 2003 规则大小限制,所以我想合并/删除我的规则。我希望能够看到所有规则,而不是一次编辑一个。Outlook 规则的导出格式是一些二进制“*.rwz”文件。
有没有办法将 Outlook 规则导出到文本或 Excel 文件?
答案1
我怀疑你运气不佳......这是一种经典的 MS 专有格式。
但是,规则向导界面的子集可通过 VBA 支持 - 请参阅http://msdn.microsoft.com/en-us/library/bb206763.aspx了解详情。您可以编写一些脚本来将规则导出为人类可读的,但它可能无法涵盖所有规则。
祝你好运!
答案2
自由的https://rwzreader.codeplex.com/ - 通过突出显示一个或多个规则并拖动以重新排序来组织规则,或使用向上/向下按钮 - 通过突出显示两个或更多规则并单击排序按钮对规则进行排序 - 将组织的 RWZ 文件另存为其他文件或将规则直接保存到 Outlook
答案3
图书馆https://github.com/hughbe/OutlookRulesReader包含用于读取和写入 Outlook 规则文件的规范和参考实现库(以 Swift 语言编写)
可以找到格式的完整描述这里
答案4
我修改了我找到的一些代码,并让这个宏以适合电子表格的制表符分隔格式列出所有规则。也许不太优雅,但似乎有效。我还借用了另一个宏,用于找出哪些规则适用于给定的选定文件夹。
Sub ListRules() ' Created: 20200726
'Modified by www.jfkelley.com
'I impose no copyright conditions on the parts of this macro that I wrote. Enjoy.
'Based on: http://www.slipstick.com/outlook/rules/create-list-rules/
'This will cull out all the Outlook Rules you have and print them out to a TXT file in your Temp directory.
'It will also OPEN that TXT file using default editor (e.g., Notepad/Notepad++)
'The data is tab-delimited so you can copy/paste it right into Excel.
'It currently only features the 5 conditions of most interest to me,
'but it should also enumerate any other conditions that are used in case you want to add those columns explicitly.
Dim colStores As Outlook.Stores
Dim oFileSys As Object
Dim oStore As Outlook.Store
Dim oRoot As Outlook.Folder
Dim oCondition As Outlook.RuleCondition
Dim oCondfrom As Outlook.RuleCondition
Dim oAction As Outlook.RuleAction
Dim colRules As Object
Dim oRule As Outlook.Rule
Dim oInbox As Outlook.Folder
Dim oMoveTarget As Outlook.Folder
Dim sOutput As String
Dim myVar As Variant
Dim dR As Object
Set dR = CreateObject("Scripting.Dictionary")
dR.Add olConditionAccount, "olConditionAccount"
dR.Add olConditionAnyCategory, "olConditionAnyCategory"
dR.Add olConditionBody, "olConditionBody"
dR.Add olConditionBodyOrSubject, "olConditionBodyOrSubject"
dR.Add olConditionCategory, "olConditionCategory"
dR.Add olConditionCc, "olConditionCc"
dR.Add olConditionDateRange, "olConditionDateRange"
dR.Add olConditionFlaggedForAction, "olConditionFlaggedForAction"
dR.Add olConditionFormName, "olConditionFormName"
dR.Add olConditionFrom, "olConditionFrom"
dR.Add olConditionFromAnyRssFeed, "olConditionFromAnyRssFeed"
dR.Add olConditionFromRssFeed, "olConditionFromRssFeed"
dR.Add olConditionHasAttachment, "olConditionHasAttachment"
dR.Add olConditionImportance, "olConditionImportance"
dR.Add olConditionLocalMachineOnly, "olConditionLocalMachineOnly"
dR.Add olConditionMeetingInviteOrUpdate, "olConditionMeetingInviteOrUpdate"
dR.Add olConditionMessageHeader, "olConditionMessageHeader"
dR.Add olConditionNotTo, "olConditionNotTo"
dR.Add olConditionOnlyToMe, "olConditionOnlyToMe"
dR.Add olConditionOOF, "olConditionOOF"
dR.Add olConditionOtherMachine, "olConditionOtherMachine"
dR.Add olConditionProperty, "olConditionProperty"
dR.Add olConditionRecipientAddress, "olConditionRecipientAddress"
dR.Add olConditionSenderAddress, "olConditionSenderAddress"
dR.Add olConditionSenderInAddressBook, "olConditionSenderInAddressBook"
dR.Add olConditionSensitivity, "olConditionSensitivity"
dR.Add olConditionSentTo, "olConditionSentTo"
dR.Add olConditionSizeRange, "olConditionSizeRange"
dR.Add olConditionSubject, "olConditionSubject"
dR.Add olConditionTo, "olConditionTo"
dR.Add olConditionToOrCc, "olConditionToOrCc"
dR.Add olConditionUnknown, "olConditionUnknown"
'On Error Resume Next
Set oFileSys = CreateObject("Scripting.FileSystemObject")
'Create a folder named Rules on your C drive or change the path to use an existing folder
Dim fnp As String
fnp = Environ("temp") & "\OLFilterList.txt"
If oFileSys.FileExists(fnp) Then
oFileSys.DeleteFile (fnp)
End If
Open fnp For Output As #1
Set colStores = Application.Session.Stores
Set oStore = colStores(1)
Set oRoot = oStore.GetRootFolder
Set colRules = oStore.GetRules
Dim stHdr As String, stName As String, stToFolder As String, stFrom As String, stSenderAddress As String, stSentTo As String, stRecipientAddress As String, stOthers As String
stHdr = "Order" & Chr(9) & "Name" & Chr(9) & "ToFolder" & Chr(9) & "From" & Chr(9) & "SenderAddress" & Chr(9) & "SentTo" & Chr(9) & "RecipientAddress" & Chr(9) & "OtherConditions"
Print #1, stHdr
For Each oRule In colRules
stName = oRule.Name
stToFolder = "??"
stFrom = ""
stSenderAddress = ""
stSentTo = ""
stRecipientAddress = ""
stOthers = ""
For Each oAction In oRule.Actions
If oAction.Enabled = True Then
If oAction.ActionType = olRuleActionMoveToFolder Then
stToFolder = oAction.Folder.FolderPath
End If
'add more actions here
End If
Next
For Each oCondition In oRule.Conditions
If oCondition.Enabled = True Then
If oCondition.ConditionType = olConditionFrom Then
stFrom = oRule.Conditions.From.Recipients(1)
ElseIf oCondition.ConditionType = olConditionSenderAddress Then
For Each myVar In oRule.Conditions.SenderAddress.Address
If stSenderAddress <> "" Then stSenderAddress = stSenderAddress & "; "
stSenderAddress = stSenderAddress & myVar
Next
ElseIf oCondition.ConditionType = olConditionSentTo Then
For Each myVar In oRule.Conditions.SentTo.Recipients
If stSentTo <> "" Then stSentTo = stSentTo & "; "
stSentTo = stSentTo & myVar
Next
ElseIf oCondition.ConditionType = olConditionRecipientAddress Then
For Each myVar In oRule.Conditions.RecipientAddress.Address
If stRecipientAddress <> "" Then stRecipientAddress = stRecipientAddress & "; "
stRecipientAddress = stRecipientAddress & myVar
Next
Else
If stOthers <> "" Then stOthers = stOthers & "; "
stOthers = stOthers & dR(oCondition.ConditionType)
End If
'add more ElseIf conditions above and follow the pattern for the header (above) and data (below).
End If
Next
stOutput = (oRule.ExecutionOrder) & Chr(9) & stName & Chr(9) & stToFolder & Chr(9) & stFrom & Chr(9) & stSenderAddress & Chr(9) & stSentTo & Chr(9) & stRecipientAddress & Chr(9) & stOthers
Print #1, stOutput
Next
Close #1
Dim fso As Object
Set fso = CreateObject("shell.application")
sfile = fnp
fso.Open (sfile)
End Sub
Sub EnumerateRelatedRules() ' Created 20200726
'Source: https://techniclee.wordpress.com/2011/06/18/finding-rules-related-to-a-folder-in-outlook/
'The author also had some code to make this a context-menu (right-click) item, but I couldn't make it work.
'So: Just select a folder (or email in a folder) and use Developer tab -> Macros to run it.
'Works nicely in conjunction with my other spreadsheet report on all the Outlook Rules.
' - Posted here: https://superuser.com/questions/92197/export-outlook-2003-rules-to-text/1571875#1571875
Dim olkRul As Outlook.Rule, olkAct As Outlook.RuleAction, strRules As String
For Each olkRul In Application.Session.DefaultStore.GetRules()
For Each olkAct In olkRul.Actions
If olkAct.ActionType = olRuleActionCopyToFolder Or olkAct.ActionType = olRuleActionMoveToFolder Then
If olkAct.Enabled Then
If olkAct.Folder = Application.ActiveExplorer.CurrentFolder Then 'olkCurrentFolder Then
strRules = strRules & olkRul.Name & vbCrLf
End If
End If
End If
Next
Next
If strRules = "" Then
strRules = "None"
End If
MsgBox strRules, vbInformation + vbOKOnly, "Rules Related to this Folder"
Set olkRul = Nothing
Set olkAct = Nothing
End Sub