Filing Rule Types
MacroView Managed Filing supports all the types of email filing rule that are currently available for personal filing rules in MacroView DMS and DMS Pro. For example:
- To contains fredd.nurk@acme.com
- Subject contains 'macroview' AND From contains 'dennis'
- Body contains 'macroview dms'
- CC contains any of these words 'bob', 'carol', 'ted', 'alice'
In addition, MacroView Managed Filing support filing rules that use filing tags (aka luggage tags) in the subject of an email to automatically file the email.
Managed Filing Rules are defined in an configuration file that is stored in a central location in SharePoint which is retrieved by MacroView DMS or DMS Pro when Outlook is started, or when MacroView Mail is initiated.
The easiest way to create a rules configuration file is using the MacroView Managed Filing Rule Builder.
The rest of this article explains in detail the structure of the rules rule and how to create and test your own corporate filing rules without using the MacroView Managed Filing Rules Builder.
Rules structure and configuration
The rules XML file format is as follows:
<CorporateWorkflowRules>
<Rules>
Rule 1...
Rule 2...
Rule 3...
<\Rules>
<CorporateWorkflowRules>
Each rule has a number of components:
<Section> | Values | Purpose |
CorporateWorkFlowRule | Start and End marker for each rule | |
Expressions | Defines all of the property and match conditions for the rule. | |
WorkflowExpression | Defines a single rule condition. This section can be repeated if there are multiple conditions for the rule. | |
KeywordMatchType | All, Any, None or Regex | What type match of condition to apply. |
Keywords | Text | The text to match in the specified MailProperty |
CaseSensitive | true or false | Is the keywords match case sensitive |
MatchEntireWord | true or false |
Match only entire words specified in the keywords property |
MailProperty | ||
DisplayName | Text | Display name of the property |
PropertyName | ToSMTPAddresses, FromSMTPAddresses, CCSMTPAddresses, BCCSMTPAddresses, Subject, Body. TransfortMessageHeaders | Which email property does this expression use |
RuleEnabled | true or false | true or false |
SavePath | URL | URL to save location in SharePoint |
SavePathProperty | Option Start and End marker for settings to define a unique reference code rule | |
Object Type | Library or Folder | The object type of item with the tag <value> as a searchable property |
InternalName | Text | 'Title' or other searchable SharePoint property where referenced <value> is stored. |
Value | Text | The value of the <InternalName> property. This can be a regex named group from the tag definition. |
Name | Text | Display name for the rule |
SaveWebAppPath | URL | URL to the save paths web app |
Scope | Incoming, Outgoing or Both | Whether the rule applies to incoming, outgoing or both incoming and outgoing emails |
AllowInsertingTag | true or false | Can this rule use used to insert a filing tag in the email subject. Only applicable to Tag based rules. |
So, a complete rule named Sample Filing Rule which saves any incoming email with a subject containing the string ACME to the https://tenant.sharepoint.com/sites/library/Emails folder might look like the following:
<CorporateWorkflowRules>
<Rules>
<CorporateWorkflowRule>
<Expressions>
<WorkflowExpression>
<KeywordMatchType>All</KeywordMatchType>
<Keywords>ACME</Keywords>
<CaseSensitive>false</CaseSensitive>
<MatchEntireWord>false</MatchEntireWord>
<MailProperty>
<DisplayName>Subject</DisplayName>
<PropertyName>Subject</PropertyName>
</MailProperty>
</WorkflowExpression>
</Expressions>
<RuleEnabled>true</RuleEnabled
<SavePath>https://tenant.sharepoint.com/sites/library/Emails</SavePath>
<Name>Sample Filing Rule</Name>
<SaveWebAppPath>https://tenant.sharepoint.com/</SaveWebAppPath>
<Scope>Incoming</Scope>
<AllowInsertingTag>false</AllowInsertingTag>
</CorporateWorkflowRule>
</Rules>
</CorporateWorkflowRules>
Advanced Filing Tag based rules
MacroView Managed Filing support filing rules that use filing tags (aka luggage tags) in the subject of an email to automatically file that email.
To create this type of this type the <KeywordMatchType> for the rule should be set to RegEx and the <Keywords> can then contain a Regular Expression to identify a string in the email subject.
For example:
<Keywords>\[MG-([a-zA-Z]{5})\]</Keywords> would match [MG-ABCDE] or [MG-ZyXwV] but not [MG-XYX]
<Keywords>\[MV-([0-9]\]</Keywords> would match [MV-123] or [MV-987654] but not [MV-ABC123]
Refer to this online tool for a more information on defining and testing Regular Expressions
Using parts of the filing tag to define the save location
By adding named groups to the Regular Expression used to define the rules <Keywords> you can use these same named groups to substitute parts of the <SavePath> URL. This allows a single filing rule to cover any number of save locations, provided that the URL for each location has a consistent URL structure. The advantage is that a new rule is not required when new areas are created.
For example, the below rule will automatically save any incoming or outgoing email with a subject containing a tag in the format [MV-C0000-M1111] to the Emails folder in matter number 1111 of the client number 0000
i.e. https://tenant.sharepoint.com/sites/clients/C0000/matters/1111/Email folder
<CorporateWorkflowRules>
<Rules>
<CorporateWorkflowRule>
<Expressions>
<WorkflowExpression>
<KeywordMatchType>Regex</KeywordMatchType>
<Keywords>\[MV-(?<ClientNo>C[\d]{4})-M(?<MatterNo>[\d]{4})\]</Keywords>
<CaseSensitive>false</CaseSensitive>
<MatchEntireWord>false</MatchEntireWord>
<MailProperty>
<DisplayName>Subject</DisplayName>
<PropertyName>Subject</PropertyName>
</MailProperty>
</WorkflowExpression>
</Expressions>
<RuleEnabled>true</RuleEnabled>
<SavePath>https://tenant.sharepoint.com/sites/clients/<ClientNo>/matters/<MatterNo>/Email</SavePath>
<Name>[MV-C1234-M5678] Save to Client > Matter > Email folder</Name>
<SaveWebAppPath>https://tenant.sharepoint.com/</SaveWebAppPath>
<Scope>Both</Scope>
<AllowInsertingTag>true</AllowInsertingTag>
</CorporateWorkflowRule>
</Rules>
</CorporateWorkflowRules>
When using filing tag based rules (i.e. <KeywordMatchType> = RegEx) you can set <AllowInsertingTag> to true if you want users to be able to insert the tag corresponding with a selected location into the subject of emails using the Insert Tag or Tag and Save options on the MacroView ribbon in Outlook. See Inserting Managed Filing filing tags to emails for more information.
Using part of the filing tag to define a unique save location
If the location you want to save an email has a unique reference code or number which is stored in a searchable SharePoint property such as the start of the folder or document set title, or in a metadata property of a document set, a rule can be created to locate that library, folder or document set wherever it is in your SharePoint store and save the email to a location relative to that library, folder or document set.
This can be particular useful if each of your projects or matters has a unique number across all sites but the sites do not have a consistent URL name or structure because the filing tag does not need to include the site reference. For example, for matter 12345 in client site AAA the tag could simply be [12345] rather than [AAA-12345] because matter 12345 does not exist under any other client site.
* these unique save location rule are supported in DMS 8.9.784 or later
Sample rules
Below are a number of sample filing rules to get you started. To add any of these rules to your corporate rules configuration file simply copy them into your corporate rules file file between the <Rules> and </Rules>
If you do not already have a Managed Filing rules file, you can download the Managed Filing Rules Template.
Incoming emails from a particular email address
The following rule would identify incoming emails from john.smith@gmail.com and save the email to: https://tenant.sharepoint.com/sites/hr/emp765/received emails
<CorporateWorkflowRule>
<Expressions>
<WorkflowExpression>
<KeywordMatchType>All</KeywordMatchType>
<Keywords>john.smith@gmail.com</Keywords>
<CaseSensitive>false</CaseSensitive>
<MatchEntireWord>false</MatchEntireWord>
<MailProperty>
<DisplayName>From</DisplayName>
<PropertyName>FromSMTPAddresses</PropertyName>
</MailProperty>
</WorkflowExpression>
</Expressions>
<RuleEnabled>true</RuleEnabled>
<SavePath>https://tenant.sharepoint.com/sites/hr/emp765/received emails</SavePath>
<Name>Email from john.smith@gmail.com to HR folder</Name>
<SaveWebAppPath>https://tenant.sharepoint.com/</SaveWebAppPath>
<Scope>Incoming</Scope>
<AllowInsertingTag>false</AllowInsertingTag>
</CorporateWorkflowRule>
Subject containing a 2 part code for client and project
The following rule would identify [MV-C001-M02] in the subject of an incoming where C001 is the client code and P02 is the project number for that client, and save the email to:
https://tenant.sharepoint.com/sites/C001/projects/02-Sample Project/Emails
<CorporateWorkflowRule>
<Expressions>
<WorkflowExpression>
<KeywordMatchType>Regex</KeywordMatchType>
<Keywords>\[MV-(?<ClientNumber>C[\d]{3})-P(?<ProjectNumber>[\d]{2})\]</Keywords>
<CaseSensitive>false</CaseSensitive>
<MatchEntireWord>false</MatchEntireWord>
<MailProperty>
<DisplayName>Subject</DisplayName>
<PropertyName>Subject</PropertyName>
</MailProperty>
</WorkflowExpression>
</Expressions>
<RuleEnabled>true</RuleEnabled>
<SavePath>https://tenant.sharepoint.com/sites/<ClientNumber>/projects/<ProjectNumber>([0-9A-Za-z- ]+)/Email</SavePath>
<Name>[MV-C123-P78] Save to Client > Project > Email folder</Name>
<SaveWebAppPath>https://tenanat.sharepoint.com/</SaveWebAppPath>
<Scope>Incoming</Scope>
<AllowInsertingTag>true</AllowInsertingTag>
</CorporateWorkflowRule>
Subject containing a single code for both client and matter
The following rule would identify [ABC0143] in the subject of an incoming or outgoing where ABC01 is the client code and ABC0143 is the matter number, and save the email to:
https://tenant.sharepoint.com/sites/ABC01/Matters/ABC0143-Sample Matter
<CorporateWorkflowRule>
<Expressions>
<WorkflowExpression>
<KeywordMatchType>Regex</KeywordMatchType>
<Keywords>\[(?<MatterNumber>(?<ClientNumber>[a-zA-Z0-9]{5})[\d]{1,3})\]</Keywords>
<CaseSensitive>false</CaseSensitive>
<MatchEntireWord>false</MatchEntireWord>
<MailProperty>
<DisplayName>Subject</DisplayName>
<PropertyName>Subject</PropertyName>
</MailProperty>
</WorkflowExpression>
</Expressions>
<RuleEnabled>true</RuleEnabled>
<SavePath>https://tenant.sharepoint.com/sites/<ClientNumber>/Matters/<MatterNumber>([0-9A-Za-z ]+)</SavePath>
<Name>[MatterNo] Save to Client > Matter folder</Name>
<SaveWebAppPath>https://tenant.sharepoint.com/</SaveWebAppPath>
<Scope>Both</Scope>
<AllowInsertingTag>true</AllowInsertingTag>
</CorporateWorkflowRule>
Subject containing a unique code for a matter in any client site
The following rule would identify [M12345] in the subject of an incoming or outgoing where M12345 is the matter code and save the email to the Emails folder for that matter:
https://tenant.sharepoint.com/sites/anysite/Matters/M12345-Sample Matter/Emails
<CorporateWorkflowRule>
<Expressions>
<WorkflowExpression>
<KeywordMatchType>Regex</KeywordMatchType>
<Keywords>\[(?<MatterNumber>M[0-9]{5})\]</Keywords>
<CaseSensitive>false</CaseSensitive>
<MatchEntireWord>false</MatchEntireWord>
<MailProperty>
<DisplayName>Subject</DisplayName>
<PropertyName>Subject</PropertyName>
</MailProperty>
</WorkflowExpression>
</Expressions>
<RuleEnabled>true</RuleEnabled>
<SavePath>https://tenant.sharepoint.com/sites/*/Emails/SavePath>
<SavePathProperty>
<ObjectType>Folder</ObjectType>
<InternalName>Title</InternalName>
<Value><MatterNumber></Value>
</SavePathProperty>
<Name>[MatterNo] Save to Email folder for matter</Name>
<SaveWebAppPath>https://tenant.sharepoint.com/</SaveWebAppPath>
<Scope>Both</Scope>
<AllowInsertingTag>true</AllowInsertingTag>
</CorporateWorkflowRule>
See Creating Managed Filing rules for unique locations for more information on creating this type of rule.
Prevent specific emails from matching other rules
See Creating a Managed Filing blacklist rule for information on how to exclude specific emails form saving when they match one of your existing filing rules.
Testing your rules
Save your rules XML file to a test library or folder in SharePoint then close down Outlook and exit the DMS local Service.
Next open the Email Filing Rules dialog by clicking on the Manage Rules button from the MacroView ribbon in Outlook and set the Managed rules file path setting on the Managed tab of the Email Filing Rules dialog. Once set you should see a list of your rules in the box above.
Make sure Enable Managed Filing rules is checked and then try out the new rules by either sending or receiving emails that match the rules. Alternatively, if there are already emails matching the rules in your Inbox or Sent Items folders, simply select them and click Run Filing Rules button on the MacroView tab in Outlook.
If your emails match a rule they with be marked in Outlook as either Saved to SharePoint by Managed Filing or Not AutoFiled by Managed Filing.
For more information on when these categories are applied refer to How to tell which emails have been saved