From 24193737d5fca502fe34c4bb58142eed0020710c Mon Sep 17 00:00:00 2001 From: James R T Date: Tue, 5 Oct 2021 17:08:17 +0800 Subject: [PATCH] Add new LKYCIC rule --- README.md | 2 ++ SUTDigest/OutlookWrapper.cs | 29 ++++++++++++++++++++++++++++- SUTDigest/SUTDigest.csproj | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 49adddb..4118e5b 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Alternatively, you can clone this repository, build the executable yourself and - Office of Research - Office of International Relations - HASS Events + - LKYCIC ### Rules @@ -66,6 +67,7 @@ Alternatively, you can clone this repository, build the executable yourself and - 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. + - Filter and move all emails from [`lkycic@sutd.edu.sg`](mailto:lkycic@sutd.edu.sg) to the LKYCIC folder. ## Feedback diff --git a/SUTDigest/OutlookWrapper.cs b/SUTDigest/OutlookWrapper.cs index b50bbad..bc12af6 100644 --- a/SUTDigest/OutlookWrapper.cs +++ b/SUTDigest/OutlookWrapper.cs @@ -215,7 +215,8 @@ public void CreateFolders() socialMediaReportFolder = null, researchFolder = null, intlRelationsFolder = null, - hassEventsFolder = null; + hassEventsFolder = null, + lkycicFolder = null; Outlook.Folders rootFolderFolders = null, othersSubfolders = null; @@ -248,6 +249,7 @@ public void CreateFolders() researchFolder = GetSubFolder(@"Office of Research", othersFolder, application); intlRelationsFolder = GetSubFolder(@"Office of International Relations", othersFolder, application); hassEventsFolder = GetSubFolder(@"HASS Events", othersFolder, application); + lkycicFolder = GetSubFolder(@"LKYCIC", othersFolder, application); } catch (Exception ex) { @@ -272,6 +274,7 @@ public void CreateFolders() ReleaseComObject(researchFolder); ReleaseComObject(intlRelationsFolder); ReleaseComObject(hassEventsFolder); + ReleaseComObject(lkycicFolder); ReleaseComObject(store); ReleaseComObject(session); } @@ -576,6 +579,30 @@ public void CreateRules() rules.Save(true); } + + string lkycicRuleName = "LKYCIC Emails"; + + if (!RuleExist(lkycicRuleName, rules)) + { + Outlook.MAPIFolder destinationFolder = GetFolder(rootFolder.FolderPath + @"\Others\LKYCIC", application); + + Outlook.Rule rule = rules.Create(lkycicRuleName, Outlook.OlRuleType.olRuleReceive); + Outlook.RuleConditions ruleConditions = rule.Conditions; + + Outlook.ToOrFromRuleCondition senderAddressRuleCondition = ruleConditions.From; + senderAddressRuleCondition.Recipients.Add("lkycic@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 5ffab3f..d9df837 100644 --- a/SUTDigest/SUTDigest.csproj +++ b/SUTDigest/SUTDigest.csproj @@ -11,7 +11,7 @@ SUTD Outlook Mail Classifier/Organizer. true true - 1.0.3 + 1.0.4 https://github.com/jamestiotio/SUTDigest https://github.com/jamestiotio/SUTDigest