diff --git a/README.md b/README.md index 74f3aa9..6576167 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Alternatively, you can clone this repository, build the executable yourself and - UTOP - IAP Admin - Fabrication Lab + - Entrepreneurship ### Rules @@ -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 diff --git a/SUTDigest/OutlookWrapper.cs b/SUTDigest/OutlookWrapper.cs index 8f62473..071f256 100644 --- a/SUTDigest/OutlookWrapper.cs +++ b/SUTDigest/OutlookWrapper.cs @@ -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; @@ -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) { @@ -296,6 +298,7 @@ public void CreateFolders() ReleaseComObject(utopFolder); ReleaseComObject(iapAdminFolder); ReleaseComObject(fablabFolder); + ReleaseComObject(entrepreneurshipFolder); ReleaseComObject(store); ReleaseComObject(session); } @@ -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) { diff --git a/SUTDigest/SUTDigest.csproj b/SUTDigest/SUTDigest.csproj index c8c01d6..1d3d4a9 100644 --- a/SUTDigest/SUTDigest.csproj +++ b/SUTDigest/SUTDigest.csproj @@ -11,7 +11,7 @@ SUTD Outlook Mail Classifier/Organizer. true true - 1.0.10 + 1.0.11 https://github.com/jamestiotio/SUTDigest https://github.com/jamestiotio/SUTDigest