Skip to content

Commit

Permalink
Add new HASS Events rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestiotio committed Oct 5, 2021
1 parent de53115 commit a22239b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Alternatively, you can clone this repository, build the executable yourself and
- Social Media Report
- Office of Research
- Office of International Relations
- HASS Events

### Rules

Expand All @@ -55,15 +56,16 @@ 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 `marcom.sutd.edu.sg` to the Office of Marketing folder.
- Filter and move all emails from `[email protected]` to the Career Development Centre folder.
- Filter and move all emails from [`[email protected]`](mailto:[email protected]) 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.
- Filter and move all emails from `[email protected]` to the Library folder.
- Filter and move all emails from [`[email protected]`](mailto:[email protected]) to the Library folder.
- Filter and move all emails with sender addresses that contain `studentgov.sutd.edu.sg` to the Student Government folder.
- Filter and move all emails sent to `*[email protected]` to the All Students folder.
- Filter and move all emails sent to [`*[email protected]`](mailto:*[email protected]) to the All Students folder.
- Filter and move all emails with subjects that contain `Summary of coverage: Highlights of SUTD` to the News Coverage folder.
- Filter and move all emails with subjects that contain `SUTD's Social Media Report` to the Social Media Report folder.
- Filter and move all emails from `[email protected]` to the Office of Research folder.
- Filter and move all emails from `[email protected]` to the Office of International Relations folder.
- Filter and move all emails from [`[email protected]`](mailto:[email protected]) to the Office of Research folder.
- Filter and move all emails from [`[email protected]`](mailto:[email protected]) to the Office of International Relations folder.
- Filter and move all emails from [`[email protected]`](mailto:[email protected]) to the HASS Events 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 @@ -214,7 +214,8 @@ public void CreateFolders()
newsCoverageFolder = null,
socialMediaReportFolder = null,
researchFolder = null,
intlRelationsFolder = null;
intlRelationsFolder = null,
hassEventsFolder = null;
Outlook.Folders rootFolderFolders = null,
othersSubfolders = null;

Expand Down Expand Up @@ -246,6 +247,7 @@ public void CreateFolders()
socialMediaReportFolder = GetSubFolder(@"Social Media Report", othersFolder, application);
researchFolder = GetSubFolder(@"Office of Research", othersFolder, application);
intlRelationsFolder = GetSubFolder(@"Office of International Relations", othersFolder, application);
hassEventsFolder = GetSubFolder(@"HASS Events", othersFolder, application);
}
catch (Exception ex)
{
Expand All @@ -269,6 +271,7 @@ public void CreateFolders()
ReleaseComObject(socialMediaReportFolder);
ReleaseComObject(researchFolder);
ReleaseComObject(intlRelationsFolder);
ReleaseComObject(hassEventsFolder);
ReleaseComObject(store);
ReleaseComObject(session);
}
Expand Down Expand Up @@ -549,6 +552,30 @@ public void CreateRules()

rules.Save(true);
}

string hassEventsRuleName = "HASS Events Emails";

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

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

Outlook.ToOrFromRuleCondition senderAddressRuleCondition = ruleConditions.From;
senderAddressRuleCondition.Recipients.Add("[email protected]");
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.2</Version>
<Version>1.0.3</Version>
<PackageTags></PackageTags>
<RepositoryUrl>https://github.com/jamestiotio/SUTDigest</RepositoryUrl>
<PackageProjectUrl>https://github.com/jamestiotio/SUTDigest</PackageProjectUrl>
Expand Down

0 comments on commit a22239b

Please sign in to comment.