Skip to content

Commit

Permalink
Add new Entrepreneurship rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestiotio committed Nov 19, 2021
1 parent 16bd46d commit ab83420
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Alternatively, you can clone this repository, build the executable yourself and
- UTOP
- IAP Admin
- Fabrication Lab
- Entrepreneurship

### Rules

Expand All @@ -82,6 +83,7 @@ Alternatively, you can clone this repository, build the executable yourself and
- Filter and move all emails from [`utop@sutd.edu.sg`](mailto:utop@sutd.edu.sg) to the UTOP folder.
- Filter and move all emails from [`iapadmin@sutd.edu.sg`](mailto:iapadmin@sutd.edu.sg) to the IAP Admin folder.
- Filter and move all emails from [`fablab@sutd.edu.sg`](mailto:fablab@sutd.edu.sg) to the Fabrication Lab folder.
- Filter and move all emails from [`entrepreneurship@sutd.edu.sg`](mailto:entrepreneurship@sutd.edu.sg) to the Entrepreneurship folder.

## Feedback

Expand Down
29 changes: 28 additions & 1 deletion SUTDigest/OutlookWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ public void CreateFolders()
uropFolder = null,
utopFolder = null,
iapAdminFolder = null,
fablabFolder = null;
fablabFolder = null,
entrepreneurshipFolder = null;
Outlook.Folders rootFolderFolders = null,
othersSubfolders = null;

Expand Down Expand Up @@ -264,6 +265,7 @@ public void CreateFolders()
utopFolder = GetSubFolder(@"UTOP", othersFolder, application);
iapAdminFolder = GetSubFolder(@"IAP Admin", othersFolder, application);
fablabFolder = GetSubFolder(@"Fabrication Lab", othersFolder, application);
entrepreneurshipFolder = GetSubFolder(@"Entrepreneurship", othersFolder, application);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -296,6 +298,7 @@ public void CreateFolders()
ReleaseComObject(utopFolder);
ReleaseComObject(iapAdminFolder);
ReleaseComObject(fablabFolder);
ReleaseComObject(entrepreneurshipFolder);
ReleaseComObject(store);
ReleaseComObject(session);
}
Expand Down Expand Up @@ -792,6 +795,30 @@ public void CreateRules()

rules.Save(true);
}

string entrepreneurshipRuleName = "Entrepreneurship Emails";

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

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

Outlook.ToOrFromRuleCondition senderAddressRuleCondition = ruleConditions.From;
senderAddressRuleCondition.Recipients.Add("entrepreneurship@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.10</Version>
<Version>1.0.11</Version>
<PackageTags></PackageTags>
<RepositoryUrl>https://github.com/jamestiotio/SUTDigest</RepositoryUrl>
<PackageProjectUrl>https://github.com/jamestiotio/SUTDigest</PackageProjectUrl>
Expand Down

0 comments on commit ab83420

Please sign in to comment.