From a22239bb6de19a08610e444b7b0557059accacec Mon Sep 17 00:00:00 2001 From: James R T Date: Tue, 5 Oct 2021 12:16:40 +0800 Subject: [PATCH] Add new HASS Events rule --- README.md | 12 +++++++----- SUTDigest/OutlookWrapper.cs | 29 ++++++++++++++++++++++++++++- SUTDigest/SUTDigest.csproj | 2 +- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4fe1c9f..49adddb 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 `careers@sutd.edu.sg` to the Career Development Centre 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. - - Filter and move all emails from `library@sutd.edu.sg` to the Library folder. + - Filter and move all emails from [`library@sutd.edu.sg`](mailto:library@sutd.edu.sg) 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 `*AllStudents@sutd.edu.sg` to the All Students folder. + - Filter and move all emails sent to [`*AllStudents@sutd.edu.sg`](mailto:*AllStudents@sutd.edu.sg) 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 `research@sutd.edu.sg` to the Office of Research folder. - - Filter and move all emails from `global@sutd.edu.sg` to the Office of International Relations folder. + - Filter and move all emails from [`research@sutd.edu.sg`](mailto:research@sutd.edu.sg) to the Office of Research folder. + - Filter and move all emails from [`global@sutd.edu.sg`](mailto:global@sutd.edu.sg) to the Office of International Relations folder. + - Filter and move all emails from [`hassevents@sutd.edu.sg`](mailto:hassevents@sutd.edu.sg) to the HASS Events folder. ## Feedback diff --git a/SUTDigest/OutlookWrapper.cs b/SUTDigest/OutlookWrapper.cs index 477de9b..b50bbad 100644 --- a/SUTDigest/OutlookWrapper.cs +++ b/SUTDigest/OutlookWrapper.cs @@ -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; @@ -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) { @@ -269,6 +271,7 @@ public void CreateFolders() ReleaseComObject(socialMediaReportFolder); ReleaseComObject(researchFolder); ReleaseComObject(intlRelationsFolder); + ReleaseComObject(hassEventsFolder); ReleaseComObject(store); ReleaseComObject(session); } @@ -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("hassevents@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) { diff --git a/SUTDigest/SUTDigest.csproj b/SUTDigest/SUTDigest.csproj index 201d8ed..5ffab3f 100644 --- a/SUTDigest/SUTDigest.csproj +++ b/SUTDigest/SUTDigest.csproj @@ -11,7 +11,7 @@ SUTD Outlook Mail Classifier/Organizer. true true - 1.0.2 + 1.0.3 https://github.com/jamestiotio/SUTDigest https://github.com/jamestiotio/SUTDigest