[#15] MailWindow: Add email sending feature

This commit is contained in:
2024-03-05 16:32:21 +01:00
parent 0812c6a8f9
commit 74da1ba46f
8 changed files with 137 additions and 37 deletions

View File

@ -1,6 +1,9 @@
using Elwig.Helpers;
using System;
using System.ComponentModel;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
namespace Elwig.Windows {
public partial class MainWindow : Window {
@ -11,10 +14,11 @@ namespace Elwig.Windows {
VersionField.Text = "Version: " + (v == null ? "?" : $"{v.Major}.{v.Minor}.{v.Build}") + $" {App.BranchName}";
if (App.Client.Client == null) VersionField.Text += " (Unbekannt)";
if (!App.Config.Debug) {
HelpMenu.Items.Remove(TestWindowButton);
HelpMenu.Items.Remove(Menu_Help_TestWindow);
//QueryWindowButton.Visibility = Visibility.Hidden;
}
if (App.Config.UpdateUrl == null) CheckForUpdatesButton.IsEnabled = false;
if (App.Config.UpdateUrl == null) Menu_Help_Update.IsEnabled = false;
if (App.Config.Smtp == null) Menu_Help_Smtp.IsEnabled = false;
}
private void Window_Loaded(object sender, RoutedEventArgs evt) { }
@ -40,6 +44,18 @@ namespace Elwig.Windows {
await App.CheckForUpdates();
}
private async void Menu_Help_Smtp_Click(object sender, RoutedEventArgs evt) {
Mouse.OverrideCursor = Cursors.AppStarting;
try {
using var client = await Utils.GetSmtpClient();
await client!.DisconnectAsync(true);
MessageBox.Show("E-Mail-Einstellungen erfolgreich überprüft!", "Erfolg", MessageBoxButton.OK, MessageBoxImage.Information);
} catch (Exception exc) {
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
}
Mouse.OverrideCursor = null;
}
private void Menu_Database_Query_Click(object sender, RoutedEventArgs evt) {
var w = new QueryWindow();
w.Show();