Skip to content

Commit

Permalink
Add new LKYCIC rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestiotio committed Oct 5, 2021
1 parent a22239b commit 2419373
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 @@ -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

Expand All @@ -66,6 +67,7 @@ Alternatively, you can clone this repository, build the executable yourself and
- 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.
- Filter and move all emails from [`[email protected]`](mailto:[email protected]) to the LKYCIC 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 @@ -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;

Expand Down Expand Up @@ -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)
{
Expand All @@ -272,6 +274,7 @@ public void CreateFolders()
ReleaseComObject(researchFolder);
ReleaseComObject(intlRelationsFolder);
ReleaseComObject(hassEventsFolder);
ReleaseComObject(lkycicFolder);
ReleaseComObject(store);
ReleaseComObject(session);
}
Expand Down Expand Up @@ -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("[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.3</Version>
<Version>1.0.4</Version>
<PackageTags></PackageTags>
<RepositoryUrl>https://github.com/jamestiotio/SUTDigest</RepositoryUrl>
<PackageProjectUrl>https://github.com/jamestiotio/SUTDigest</PackageProjectUrl>
Expand Down

0 comments on commit 2419373

Please sign in to comment.