Skip to content

Commit

Permalink
Add new Wellbeing Services rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestiotio committed Oct 11, 2021
1 parent afa4814 commit f3fa5ce
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Alternatively, you can clone this repository, build the executable yourself and
- LKYCIC
- AI Research
- SMT
- Wellbeing Services

### Rules

Expand All @@ -72,6 +73,7 @@ Alternatively, you can clone this repository, build the executable yourself and
- Filter and move all emails from [`lkycic@sutd.edu.sg`](mailto:lkycic@sutd.edu.sg) to the LKYCIC folder.
- Filter and move all emails from [`AI_RESEARCH@sutd.edu.sg`](mailto:AI_RESEARCH@sutd.edu.sg) to the AI Research folder.
- Filter and move all emails from [`sci-math@sutd.edu.sg`](mailto:sci-math@sutd.edu.sg) to the SMT folder.
- Filter and move all emails from [`wellbeing@sutd.edu.sg`](mailto:wellbeing@sutd.edu.sg) to the Wellbeing Services folder.

## Feedback

Expand Down
30 changes: 29 additions & 1 deletion SUTDigest/OutlookWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ public void CreateFolders()
hassEventsFolder = null,
lkycicFolder = null,
aiResearchFolder = null,
smtFolder = null;
smtFolder = null,
wellbeingFolder = null;
Outlook.Folders rootFolderFolders = null,
othersSubfolders = null;

Expand Down Expand Up @@ -254,6 +255,7 @@ public void CreateFolders()
lkycicFolder = GetSubFolder(@"LKYCIC", othersFolder, application);
aiResearchFolder = GetSubFolder(@"AI Research", othersFolder, application);
smtFolder = GetSubFolder(@"SMT", othersFolder, application);
wellbeingFolder = GetSubFolder(@"Wellbeing Services", othersFolder, application);
}
catch (Exception ex)
{
Expand All @@ -280,6 +282,8 @@ public void CreateFolders()
ReleaseComObject(hassEventsFolder);
ReleaseComObject(lkycicFolder);
ReleaseComObject(aiResearchFolder);
ReleaseComObject(smtFolder);
ReleaseComObject(wellbeingFolder);
ReleaseComObject(store);
ReleaseComObject(session);
}
Expand Down Expand Up @@ -656,6 +660,30 @@ public void CreateRules()

rules.Save(true);
}

string wellbeingRuleName = "Wellbeing Services Emails";

if (!RuleExist(wellbeingRuleName, rules))
{
Outlook.MAPIFolder destinationFolder = GetFolder(rootFolder.FolderPath + @"\Others\Wellbeing Services", application);

Outlook.Rule rule = rules.Create(wellbeingRuleName, Outlook.OlRuleType.olRuleReceive);
Outlook.RuleConditions ruleConditions = rule.Conditions;

Outlook.ToOrFromRuleCondition senderAddressRuleCondition = ruleConditions.From;
senderAddressRuleCondition.Recipients.Add("wellbeing@sutd.edu.sg");
senderAddressRuleCondition.Recipients.ResolveAll();
senderAddressRuleCondition.Enabled = true;

Outlook.RuleActions ruleActions = rule.Actions;
Outlook.MoveOrCopyRuleAction moveRuleAction = ruleActions.MoveToFolder;
moveRuleAction.Folder = destinationFolder;
moveRuleAction.Enabled = true;

ruleActions.Stop.Enabled = true;

rules.Save(true);
}
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion SUTDigest/SUTDigest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Description>SUTD Outlook Mail Classifier/Organizer.</Description>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<Version>1.0.6</Version>
<Version>1.0.7</Version>
<PackageTags></PackageTags>
<RepositoryUrl>https://github.com/jamestiotio/SUTDigest</RepositoryUrl>
<PackageProjectUrl>https://github.com/jamestiotio/SUTDigest</PackageProjectUrl>
Expand Down

0 comments on commit f3fa5ce

Please sign in to comment.