diff --git a/OutlookCaseHelper.sln b/OutlookCaseHelper.sln index ff5fccc..4470606 100644 --- a/OutlookCaseHelper.sln +++ b/OutlookCaseHelper.sln @@ -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 diff --git a/OutlookCaseHelper/Form1.cs b/OutlookCaseHelper/Form1.cs index ee4851e..12989b3 100644 --- a/OutlookCaseHelper/Form1.cs +++ b/OutlookCaseHelper/Form1.cs @@ -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; diff --git a/caseh.ico b/caseh.ico new file mode 100644 index 0000000..bb4d8cb Binary files /dev/null and b/caseh.ico differ