Add custom tray icon and remove rule from selected email

This commit is contained in:
2026-03-16 20:15:15 +00:00
parent 29560bfa4a
commit 4b7c737a57
3 changed files with 47 additions and 5 deletions
+1
View File
@@ -8,6 +8,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
ProjectSection(SolutionItems) = preProject
App.config = App.config
caseh.ico = caseh.ico
OutlookHelper.cs = OutlookHelper.cs
EndProjectSection
EndProject
+46 -5
View File
@@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace OutlookCaseHelper
{
@@ -22,13 +23,14 @@ namespace OutlookCaseHelper
private void InitializeTray()
{
trayMenu = new ContextMenuStrip();
trayMenu.Items.Add("Process Selected Email", null, ProcessEmail_Click);
trayMenu.Items.Add("Remove Rule", null, RemoveRule_Click);
trayMenu.Items.Add("Create Rule (Selected Email)", null, ProcessEmail_Click);
trayMenu.Items.Add("Remove Rule (Selected Email)", null, RemoveRuleFromSelected_Click);
trayMenu.Items.Add("Remove Rule (Manual ID)", null, RemoveRule_Click);
trayMenu.Items.Add("-");
trayMenu.Items.Add("Exit", null, Exit_Click);
trayIcon = new NotifyIcon();
trayIcon.Icon = SystemIcons.Application;
trayIcon.Icon = new Icon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "casenew.ico"));
trayIcon.ContextMenuStrip = trayMenu;
trayIcon.Text = "Outlook Case Manager";
trayIcon.Visible = true;
@@ -43,7 +45,7 @@ namespace OutlookCaseHelper
if (string.IsNullOrEmpty(trackingId))
{
MessageBox.Show(
"No email selected or ID not found in subject.\n\nExpected format: Title - TrackingID1111111111111111",
"No email selected or ID not found in subject.\n\nExpected format: Title - TrackingID#1111111111111111",
"Warning",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
@@ -106,6 +108,46 @@ namespace OutlookCaseHelper
}
}
// NOVO: Remove Rule pelo email selecionado no Outlook
private void RemoveRuleFromSelected_Click(object? sender, EventArgs e)
{
try
{
var trackingId = outlookHelper.GetSelectedEmailTrackingId();
if (string.IsNullOrEmpty(trackingId))
{
MessageBox.Show(
"No email selected or ID not found in subject.\n\nExpected format: Title - TrackingID#1111111111111111",
"Warning",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
return;
}
bool success = outlookHelper.RemoveRuleAndMoveToClosed(trackingId);
if (success)
{
MessageBox.Show(
$"Rule removed successfully!\n\nFolder moved to: Inbox > Cases > Closed\nTrackingID: {trackingId}",
"Success",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
MessageBox.Show(
"Error removing rule. Check if folder exists and Outlook is open.",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"Error: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void TrayIcon_MouseDoubleClick(object? sender, MouseEventArgs e)
{
ProcessEmail_Click(null, EventArgs.Empty);
@@ -117,7 +159,6 @@ namespace OutlookCaseHelper
Application.Exit();
}
// Simple input dialog
private class InputForm : Form
{
private TextBox txtInput;
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB