Skip to content

Commit

Permalink
Add new Interest Groups rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestiotio committed Jan 30, 2022
1 parent ab83420 commit fe3383b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Alternatively, you can clone this repository, build the executable yourself and

- Others
- Student Clubs
- Interest Groups
- Office of Marketing
- Career Development Centre
- Whatz Newz
Expand Down Expand Up @@ -64,6 +65,7 @@ Alternatively, you can clone this repository, build the executable yourself and
- Server-Side:
- Filter and move all emails with sender addresses that contain `club.sutd.edu.sg` to the Student Clubs folder.
- Filter and move all emails with sender addresses that contain `ig.sutd.edu.sg` to the Interest Groups folder.
- Filter and move all emails with sender addresses that contain `marcom.sutd.edu.sg` to the Office of Marketing folder.
- Filter and move all emails from [`careers@sutd.edu.sg`](mailto:careers@sutd.edu.sg) to the Career Development Centre folder.
- Filter and move all emails with subjects that contain `Whatz Newz by Office of Student Life` to the Whatz Newz folder.
Expand Down
32 changes: 29 additions & 3 deletions SUTDigest/OutlookWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public void CreateFolders()
Outlook.Folder rootFolder = null,
othersFolder = null,
studentClubsFolder = null,
interestGroupsFolder = null,
marketingFolder = null,
cdcFolder = null,
whatzNewzFolder = null,
Expand Down Expand Up @@ -246,6 +247,7 @@ public void CreateFolders()
othersSubfolders = othersFolder.Folders;

studentClubsFolder = GetSubFolder(@"Student Clubs", othersFolder, application);
interestGroupsFolder = GetSubFolder(@"Interest Groups", othersFolder, application);
marketingFolder = GetSubFolder(@"Office of Marketing", othersFolder, application);
cdcFolder = GetSubFolder(@"Career Development Centre", othersFolder, application);
whatzNewzFolder = GetSubFolder(@"Whatz Newz", othersFolder, application);
Expand Down Expand Up @@ -279,6 +281,7 @@ public void CreateFolders()
ReleaseComObject(othersFolder);
ReleaseComObject(othersSubfolders);
ReleaseComObject(studentClubsFolder);
ReleaseComObject(interestGroupsFolder);
ReleaseComObject(marketingFolder);
ReleaseComObject(cdcFolder);
ReleaseComObject(whatzNewzFolder);
Expand Down Expand Up @@ -320,13 +323,13 @@ public void CreateRules()
rootFolder = store.GetRootFolder();

// Rules are identified by name
string studentClubRuleName = "Emails from Student Clubs";
string studentClubsRuleName = "Emails from Student Clubs";

if (!RuleExist(studentClubRuleName, rules))
if (!RuleExist(studentClubsRuleName, rules))
{
Outlook.MAPIFolder destinationFolder = GetFolder(rootFolder.FolderPath + @"\Others\Student Clubs", application);

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

Outlook.AddressRuleCondition senderAddressRuleCondition = ruleConditions.SenderAddress;
Expand All @@ -345,6 +348,29 @@ public void CreateRules()
rules.Save(true);
}

string interestGroupsRuleName = "Emails from Interest Groups";

if (!RuleExist(interestGroupsRuleName, rules))
{
Outlook.MAPIFolder destinationFolder = GetFolder(rootFolder.FolderPath + @"\Others\Interest Groups", application);

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

Outlook.AddressRuleCondition senderAddressRuleCondition = ruleConditions.SenderAddress;
senderAddressRuleCondition.Address = new string[] { "ig.sutd.edu.sg" };
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);
}

string marketingRuleName = "Emails from Office of Marketing";

if (!RuleExist(marketingRuleName, rules))
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.11</Version>
<Version>1.0.12</Version>
<PackageTags></PackageTags>
<RepositoryUrl>https://github.com/jamestiotio/SUTDigest</RepositoryUrl>
<PackageProjectUrl>https://github.com/jamestiotio/SUTDigest</PackageProjectUrl>
Expand Down

0 comments on commit fe3383b

Please sign in to comment.