Sending mails works
This commit is contained in:
12
Massmailer.UI/Views/MainView.xaml
Normal file
12
Massmailer.UI/Views/MainView.xaml
Normal file
@@ -0,0 +1,12 @@
|
||||
<Window x:Class="Massmailer.UI.MainView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Massmailer.UI"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Button x:Name="BtnSend" Click="Button_Click" Content="Send"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
71
Massmailer.UI/Views/MainView.xaml.cs
Normal file
71
Massmailer.UI/Views/MainView.xaml.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Massmailer.Shared.Events;
|
||||
using Massmailer.Shared.Logic;
|
||||
using Massmailer.Shared.Model;
|
||||
using PubSub;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Massmailer.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainView : Window
|
||||
{
|
||||
private readonly Hub hub = new Hub();
|
||||
|
||||
public MainView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.hub.Subscribe<MailSentEvent>(this.MailSentEventHandler);
|
||||
}
|
||||
|
||||
private async void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var smtpSettings = new SmtpSettings
|
||||
{
|
||||
Server = "localhost",
|
||||
Port = 25,
|
||||
Username = "test@test.local",
|
||||
Password = "asdf33asdf",
|
||||
UseSsl = false,
|
||||
SenderEmail = "test@test.local",
|
||||
SenderName = "Massmailer Test",
|
||||
MaxSendRate = 60
|
||||
};
|
||||
var mailer = new Mailer(smtpSettings, this.hub);
|
||||
var recipients = new List<string>
|
||||
{
|
||||
"1@test.local",
|
||||
"2@test.local",
|
||||
"3@test.local",
|
||||
"4@test.local",
|
||||
"5@test.local",
|
||||
"6@test.local",
|
||||
"7@test.local",
|
||||
"8@test.local",
|
||||
"9@test.local",
|
||||
"10@test.local"
|
||||
};
|
||||
|
||||
await mailer.SendMailsAsync(recipients, "Hello World Subject", "Hello World Body");
|
||||
}
|
||||
|
||||
private void MailSentEventHandler(MailSentEvent mailSentEvent)
|
||||
{
|
||||
this.BtnSend.Content = $"mail sent: {mailSentEvent.Recipient} at {mailSentEvent.Timestamp}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user