diff --git a/EmailSendService.lib/EmailSendService.lib.csproj b/EmailSendService.lib/EmailSendService.lib.csproj new file mode 100644 index 0000000..2392443 --- /dev/null +++ b/EmailSendService.lib/EmailSendService.lib.csproj @@ -0,0 +1,54 @@ + + + + + Debug + AnyCPU + {1C081ED6-B778-44E9-B0D8-36FAAB09A87A} + Library + Properties + EmailSendService.lib + EmailSendService.lib + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + {772FEDB7-183B-40F1-89D1-4415997A0D1E} + SpamTools.lib + + + + \ No newline at end of file diff --git a/EmailSendService.lib/Properties/AssemblyInfo.cs b/EmailSendService.lib/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..74cb91c --- /dev/null +++ b/EmailSendService.lib/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, +// связанные со сборкой. +[assembly: AssemblyTitle("EmailSendService.lib")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EmailSendService.lib")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("1c081ed6-b778-44e9-b0d8-36faab09a87a")] + +// Сведения о версии сборки состоят из следующих четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номер сборки и номер редакции по умолчанию. +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/EmailSendService.lib/SenderService.cs b/EmailSendService.lib/SenderService.cs new file mode 100644 index 0000000..dcf5bf1 --- /dev/null +++ b/EmailSendService.lib/SenderService.cs @@ -0,0 +1,83 @@ +using SpamTools.lib.Data; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Mail; +using System.Security; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using SpamTools.lib.Database; + +namespace EmailSendService.lib +{ + public class SenderService + { + private string _ServerAdress; + private int _Port; + private bool _UseSSL; + private string _FromLogin; + private SecureString _FromPassword; + public string Subject { get; set; } + + public SenderService(string ServerAdress, int Port, bool UseSSL, string FromLogin, SecureString FromPassword) + { + _ServerAdress = ServerAdress; + _Port = Port; + _UseSSL = UseSSL; + _FromLogin = FromLogin; + _FromPassword = FromPassword; + } + + public void Send(string to, string subject, string body) + { + //string response = default(string); + using (var message = new MailMessage(_FromLogin, to)) + { + message.Subject = subject; + message.Body = body; + + using (var client = new SmtpClient(_ServerAdress, _Port)) + { + client.EnableSsl = _UseSSL; + client.Credentials = new NetworkCredential(_FromLogin, _FromPassword); + try + { + client.Send(message); + //response = $"Письмо успешно отправлено на почту {to}"; + } + catch (Exception ex) + { + //response = "Ошибка: "+ex.Message; + } + } + } + //return response; + } + /// + /// массовое отправление писем + /// + /// тема письма + /// тело письма + /// получатели письма + public void SendParallel(string subject, string body, IEnumerable recipients) + { + foreach (var recipient in recipients) + { + var sending_thread = new Thread(() => Send(recipient.EmailAdress, subject, body)); + sending_thread.IsBackground = true; + sending_thread.Start(); + } + } + public void Send(string subject, string body, IEnumerable recipients) + { + foreach (var recipient in recipients) + { + Task.Factory.StartNew(()=> Send(subject, body, recipient.EmailAdress)); + } + } + } +} diff --git a/MailSender.sln b/MailSender.sln index 9da86fb..ddb4fae 100644 --- a/MailSender.sln +++ b/MailSender.sln @@ -5,6 +5,20 @@ VisualStudioVersion = 15.0.28307.168 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MailSender", "MailSender\MailSender.csproj", "{F41CB514-4BD5-4D18-8411-7B0579F510F2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpamTools.lib", "SpamTools.lib\SpamTools.lib.csproj", "{772FEDB7-183B-40F1-89D1-4415997A0D1E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmailSendService.lib", "EmailSendService.lib\EmailSendService.lib.csproj", "{1C081ED6-B778-44E9-B0D8-36FAAB09A87A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{8BB062CE-B09C-4B1F-9E7B-612FA41317E0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpamTools.lib.Tests", "SpamTools.lib.Tests\SpamTools.lib.Tests.csproj", "{F28BF459-9A95-4B66-AC0A-D50D9216108E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hw5", "hw5\hw5.csproj", "{7BE85544-8D56-4E23-8E2E-8C1939D21427}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hw6-1", "hw6\hw6-1.csproj", "{941649D3-FC29-44DC-914B-91C388ACB211}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hw6-2", "hw6-2\hw6-2.csproj", "{749183D2-F08B-4730-B6D3-D9F410ADE740}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,10 +29,37 @@ Global {F41CB514-4BD5-4D18-8411-7B0579F510F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {F41CB514-4BD5-4D18-8411-7B0579F510F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {F41CB514-4BD5-4D18-8411-7B0579F510F2}.Release|Any CPU.Build.0 = Release|Any CPU + {772FEDB7-183B-40F1-89D1-4415997A0D1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {772FEDB7-183B-40F1-89D1-4415997A0D1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {772FEDB7-183B-40F1-89D1-4415997A0D1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {772FEDB7-183B-40F1-89D1-4415997A0D1E}.Release|Any CPU.Build.0 = Release|Any CPU + {1C081ED6-B778-44E9-B0D8-36FAAB09A87A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C081ED6-B778-44E9-B0D8-36FAAB09A87A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C081ED6-B778-44E9-B0D8-36FAAB09A87A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C081ED6-B778-44E9-B0D8-36FAAB09A87A}.Release|Any CPU.Build.0 = Release|Any CPU + {F28BF459-9A95-4B66-AC0A-D50D9216108E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F28BF459-9A95-4B66-AC0A-D50D9216108E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F28BF459-9A95-4B66-AC0A-D50D9216108E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F28BF459-9A95-4B66-AC0A-D50D9216108E}.Release|Any CPU.Build.0 = Release|Any CPU + {7BE85544-8D56-4E23-8E2E-8C1939D21427}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BE85544-8D56-4E23-8E2E-8C1939D21427}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BE85544-8D56-4E23-8E2E-8C1939D21427}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BE85544-8D56-4E23-8E2E-8C1939D21427}.Release|Any CPU.Build.0 = Release|Any CPU + {941649D3-FC29-44DC-914B-91C388ACB211}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {941649D3-FC29-44DC-914B-91C388ACB211}.Debug|Any CPU.Build.0 = Debug|Any CPU + {941649D3-FC29-44DC-914B-91C388ACB211}.Release|Any CPU.ActiveCfg = Release|Any CPU + {941649D3-FC29-44DC-914B-91C388ACB211}.Release|Any CPU.Build.0 = Release|Any CPU + {749183D2-F08B-4730-B6D3-D9F410ADE740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {749183D2-F08B-4730-B6D3-D9F410ADE740}.Debug|Any CPU.Build.0 = Debug|Any CPU + {749183D2-F08B-4730-B6D3-D9F410ADE740}.Release|Any CPU.ActiveCfg = Release|Any CPU + {749183D2-F08B-4730-B6D3-D9F410ADE740}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {F28BF459-9A95-4B66-AC0A-D50D9216108E} = {8BB062CE-B09C-4B1F-9E7B-612FA41317E0} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F5A42F05-4853-4892-8AB8-28B2CD3F0A5E} EndGlobalSection diff --git a/MailSender/App.config b/MailSender/App.config index 731f6de..983f06a 100644 --- a/MailSender/App.config +++ b/MailSender/App.config @@ -1,6 +1,17 @@ - + + + + + + + + + + + + \ No newline at end of file diff --git a/MailSender/App.xaml b/MailSender/App.xaml index 2216690..9c6a5b4 100644 --- a/MailSender/App.xaml +++ b/MailSender/App.xaml @@ -1,13 +1,14 @@ - - - - - - - - - + + + + + + + \ No newline at end of file diff --git a/MailSender/Controls/ListViewItemScheduler-custom.xaml b/MailSender/Controls/ListViewItemScheduler-custom.xaml new file mode 100644 index 0000000..d2a6b73 --- /dev/null +++ b/MailSender/Controls/ListViewItemScheduler-custom.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + Время: + + + + + + + + + + + + + diff --git a/MailSender/Controls/ListViewItemScheduler-custom.xaml.cs b/MailSender/Controls/ListViewItemScheduler-custom.xaml.cs new file mode 100644 index 0000000..b109c24 --- /dev/null +++ b/MailSender/Controls/ListViewItemScheduler-custom.xaml.cs @@ -0,0 +1,28 @@ +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 MailSender.Controls +{ + /// + /// Логика взаимодействия для ListViewItemScheduler_custom.xaml + /// + public partial class ListViewItemScheduler_custom : UserControl + { + public ListViewItemScheduler_custom() + { + InitializeComponent(); + } + } +} diff --git a/MailSender/Controls/ListViewItemScheduler.xaml b/MailSender/Controls/ListViewItemScheduler.xaml new file mode 100644 index 0000000..39f570e --- /dev/null +++ b/MailSender/Controls/ListViewItemScheduler.xaml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/MailSender/Controls/ListViewItemScheduler.xaml.cs b/MailSender/Controls/ListViewItemScheduler.xaml.cs new file mode 100644 index 0000000..d84234d --- /dev/null +++ b/MailSender/Controls/ListViewItemScheduler.xaml.cs @@ -0,0 +1,28 @@ +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 MailSender.Controls +{ + /// + /// Логика взаимодействия для ListViewItemScheduler.xaml + /// + public partial class ListViewItemScheduler : UserControl + { + public ListViewItemScheduler() + { + InitializeComponent(); + } + } +} diff --git a/MailSender/Controls/Otpraviteli.xaml b/MailSender/Controls/Otpraviteli.xaml new file mode 100644 index 0000000..5e10aeb --- /dev/null +++ b/MailSender/Controls/Otpraviteli.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/MailSender/Controls/Otpraviteli.xaml.cs b/MailSender/Controls/Otpraviteli.xaml.cs new file mode 100644 index 0000000..bd03f77 --- /dev/null +++ b/MailSender/Controls/Otpraviteli.xaml.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections; +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 MailSender.Controls +{ + /// + /// Логика взаимодействия для Otpraviteli.xaml + /// + public partial class Otpraviteli : UserControl + { + public Otpraviteli() + { + InitializeComponent(); + } + + #region PanelText + public static readonly DependencyProperty PanelTextProperty = DependencyProperty.Register( + "PanelText", typeof(string), typeof(Otpraviteli), new PropertyMetadata("Текст панели")); + + public string PanelText + { + get { return (string)GetValue(PanelTextProperty); } + set { SetValue(PanelTextProperty, value); } + } + #endregion + #region ItemsSource + public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register( + "ItemsSource", typeof(IEnumerable), typeof(Otpraviteli), new PropertyMetadata(default(IEnumerable))); + + public IEnumerable ItemsSource + { + get { return (IEnumerable)GetValue(ItemsSourceProperty); } + set { SetValue(ItemsSourceProperty, value); } + } + #endregion + #region ItemTemplate + + public static readonly DependencyProperty ItemTemplateProperty = DependencyProperty.Register( + "ItemTemplate", typeof(DataTemplate), typeof(Otpraviteli), new PropertyMetadata(default(DataTemplate))); + + public DataTemplate ItemTemplate + { + get { return (DataTemplate) GetValue(ItemTemplateProperty); } + set { SetValue(ItemTemplateProperty, value); } + } + #endregion + #region SelectedIndex + + public static readonly DependencyProperty SelectedIndexProperty = DependencyProperty.Register( + "SelectedIndex", typeof(int), typeof(Otpraviteli), new PropertyMetadata(default(int))); + + public int SelectedIndex + { + get { return (int) GetValue(SelectedIndexProperty); } + set { SetValue(SelectedIndexProperty, value); } + } + + + #endregion + #region SelectedItem + public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register( + "SelectedItem", typeof(object), typeof(Otpraviteli), new PropertyMetadata(default(object))); + + public object SelectedItem + { + get { return (object)GetValue(SelectedItemProperty); } + set { SetValue(SelectedItemProperty, value); } + } + #endregion + + #region CreateItemCommand + + public static readonly DependencyProperty CreateItemCommandProperty = DependencyProperty.Register( + "CreateItemCommand", typeof(ICommand), typeof(Otpraviteli), new PropertyMetadata(default(ICommand))); + + public ICommand CreateItemCommand + { + get { return (ICommand) GetValue(CreateItemCommandProperty); } + set { SetValue(CreateItemCommandProperty, value); } + } + #endregion + #region RemoveItemCommand + + public static readonly DependencyProperty RemoveItemCommandProperty = DependencyProperty.Register( + "RemoveItemCommand", typeof(ICommand), typeof(Otpraviteli), new PropertyMetadata(default(ICommand))); + + public ICommand RemoveItemCommand + { + get { return (ICommand) GetValue(RemoveItemCommandProperty); } + set { SetValue(RemoveItemCommandProperty, value); } + } + #endregion + #region EditItemCommand + public static readonly DependencyProperty EditItemCommandProperty = DependencyProperty.Register( + "EditItemCommand", typeof(ICommand), typeof(Otpraviteli), new PropertyMetadata(default(ICommand))); + + public ICommand EditItemCommand + { + get { return (ICommand) GetValue(EditItemCommandProperty); } + set { SetValue(EditItemCommandProperty, value); } + } + #endregion + } +} diff --git a/MailSender/Controls/Servers.xaml b/MailSender/Controls/Servers.xaml new file mode 100644 index 0000000..dad24ba --- /dev/null +++ b/MailSender/Controls/Servers.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/MailSender/Controls/Servers.xaml.cs b/MailSender/Controls/Servers.xaml.cs new file mode 100644 index 0000000..102860e --- /dev/null +++ b/MailSender/Controls/Servers.xaml.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections; +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 MailSender.Controls +{ + /// + /// Логика взаимодействия для Servers.xaml + /// + public partial class Servers : UserControl + { + public Servers() + { + InitializeComponent(); + } + #region PanelText + public static readonly DependencyProperty PanelTextProperty = DependencyProperty.Register( + "PanelText", typeof(string), typeof(Servers), new PropertyMetadata("Текст панели")); + + public string PanelText + { + get { return (string)GetValue(PanelTextProperty); } + set { SetValue(PanelTextProperty, value); } + } + #endregion + #region ItemsSource + public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register( + "ItemsSource", typeof(IEnumerable), typeof(Servers), new PropertyMetadata(default(IEnumerable))); + + public IEnumerable ItemsSource + { + get { return (IEnumerable)GetValue(ItemsSourceProperty); } + set { SetValue(ItemsSourceProperty, value); } + } + #endregion + #region ItemTemplate + + public static readonly DependencyProperty ItemTemplateProperty = DependencyProperty.Register( + "ItemTemplate", typeof(DataTemplate), typeof(Servers), new PropertyMetadata(default(DataTemplate))); + + public DataTemplate ItemTemplate + { + get { return (DataTemplate)GetValue(ItemTemplateProperty); } + set { SetValue(ItemTemplateProperty, value); } + } + #endregion + #region SelectedIndex + + public static readonly DependencyProperty SelectedIndexProperty = DependencyProperty.Register( + "SelectedIndex", typeof(int), typeof(Servers), new PropertyMetadata(default(int))); + + public int SelectedIndex + { + get { return (int)GetValue(SelectedIndexProperty); } + set { SetValue(SelectedIndexProperty, value); } + } + + + #endregion + #region SelectedItem + public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register( + "SelectedItem", typeof(object), typeof(Servers), new PropertyMetadata(default(object))); + + public object SelectedItem + { + get { return (object)GetValue(SelectedItemProperty); } + set { SetValue(SelectedItemProperty, value); } + } + #endregion + + #region CreateItemCommand + + public static readonly DependencyProperty CreateItemCommandProperty = DependencyProperty.Register( + "CreateItemCommand", typeof(ICommand), typeof(Servers), new PropertyMetadata(default(ICommand))); + + public ICommand CreateItemCommand + { + get { return (ICommand)GetValue(CreateItemCommandProperty); } + set { SetValue(CreateItemCommandProperty, value); } + } + #endregion + #region RemoveItemCommand + + public static readonly DependencyProperty RemoveItemCommandProperty = DependencyProperty.Register( + "RemoveItemCommand", typeof(ICommand), typeof(Servers), new PropertyMetadata(default(ICommand))); + + public ICommand RemoveItemCommand + { + get { return (ICommand)GetValue(RemoveItemCommandProperty); } + set { SetValue(RemoveItemCommandProperty, value); } + } + #endregion + #region EditItemCommand + public static readonly DependencyProperty EditItemCommandProperty = DependencyProperty.Register( + "EditItemCommand", typeof(ICommand), typeof(Servers), new PropertyMetadata(default(ICommand))); + + public ICommand EditItemCommand + { + get { return (ICommand)GetValue(EditItemCommandProperty); } + set { SetValue(EditItemCommandProperty, value); } + } + #endregion + } +} diff --git a/MailSender/DBClass.cs b/MailSender/DBClass.cs index 40df5f5..6f03d4c 100644 --- a/MailSender/DBClass.cs +++ b/MailSender/DBClass.cs @@ -8,5 +8,13 @@ namespace MailSender { class DBClass { + //private EmailsDataContext emails = new EmailsDataContext(); + //public IQueryable Emails + //{ + // get + // { + // return from c in emails.Emails select c; + // } + //} } } diff --git a/MailSender/EmailSendServiceClass.cs b/MailSender/EmailSendServiceClass.cs index 4233bb0..3696b4a 100644 --- a/MailSender/EmailSendServiceClass.cs +++ b/MailSender/EmailSendServiceClass.cs @@ -1,18 +1,62 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net; using System.Net.Mail; +using System.Security; +using System.Windows; +using SpamTools.lib.Data; +using SpamTools.lib.Database; namespace MailSender { class EmailSendServiceClass - { - public void Send(MainWindow mw) + { + #region vars + private string strLogin; + private string strPassword; + private string strSmtp = "smtp.yandex.ru"; + private int iSmtpPort = 25; + private string strBody; + private string strSubject; + #endregion + public EmailSendServiceClass(string sLogin, string sPassword) { - + strLogin = sLogin; + strPassword = sPassword; } - } + private void SendMail(string mail, string name) + { + using (MailMessage mm = new MailMessage(strLogin, mail)) + { + mm.Subject = strSubject; + mm.Body = "Hello world!"; + mm.IsBodyHtml = false; + SmtpClient sc = new SmtpClient(strSmtp, iSmtpPort); + sc.EnableSsl = true; + sc.DeliveryMethod = SmtpDeliveryMethod.Network; + sc.UseDefaultCredentials = false; + sc.Credentials = new NetworkCredential(strLogin, strPassword); + try + { + sc.Send(mm); + } + catch (Exception ex) + { + MessageBox.Show("Невозможно отправить письмо " + ex.ToString()); + } + } + }//private void SendMail(string mail, string name) + public void SendMails(ObservableCollection emails) + { + foreach (Sender email in emails) + { + SendMail(email.Adress, email.Name); + } + } + + } //private void SendMail(string mail, string name) } diff --git a/MailSender/MailSender.csproj b/MailSender/MailSender.csproj index 3a73bb3..ab2f033 100644 --- a/MailSender/MailSender.csproj +++ b/MailSender/MailSender.csproj @@ -35,8 +35,29 @@ 4 + + ..\packages\CommonServiceLocator.2.0.4\lib\net46\CommonServiceLocator.dll + + + ..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + ..\SpamTools.lib\bin\Debug\SpamTools.lib.dll + + + ..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll + @@ -49,6 +70,24 @@ + + ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.AvalonDock.dll + + + ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll + + + ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll + + + ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll + + + ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.DataGrid.dll + + + ..\packages\Extended.Wpf.Toolkit.3.4.0\lib\net40\Xceed.Wpf.Toolkit.dll + @@ -56,13 +95,54 @@ Designer + + ListViewItemScheduler-custom.xaml + + + ListViewItemScheduler.xaml + + + Otpraviteli.xaml + + + Servers.xaml + - + SendEndWindow.xaml + + + + + + NewEmailWindowView.xaml + + + RecipientsEditorView.xaml + + + RecipientsView.xaml + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -83,6 +163,18 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + @@ -102,6 +194,7 @@ ResXFileCodeGenerator Resources.Designer.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -110,5 +203,17 @@ + + + + + + {1c081ed6-b778-44e9-b0d8-36faab09a87a} + EmailSendService.lib + + + + + \ No newline at end of file diff --git a/MailSender/MainWindow.xaml b/MailSender/MainWindow.xaml index 568d53a..837e239 100644 --- a/MailSender/MainWindow.xaml +++ b/MailSender/MainWindow.xaml @@ -4,8 +4,16 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:MailSender" + xmlns:data="clr-namespace:SpamTools.lib.Data;assembly=SpamTools.lib" + xmlns:db="clr-namespace:SpamTools.lib.Database;assembly=SpamTools.lib" + xmlns:fa="http://schemas.fontawesome.io/icons/" + xmlns:xwt="http://schemas.xceed.com/wpf/xaml/toolkit" + xmlns:view="clr-namespace:MailSender.View" + xmlns:controls="clr-namespace:MailSender.Controls" mc:Ignorable="d" - Title="MainWindow" Height="450" Width="800"> + Title="{Binding Title}" Height="450" Width="800" + DataContext="{Binding MainWindowModel, Source={StaticResource Locator}}"> + @@ -17,32 +25,157 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - -