diff --git a/App.config b/App.config new file mode 100644 index 0000000..3482ace --- /dev/null +++ b/App.config @@ -0,0 +1,26 @@ + + + + +
+ + + + + + + + + 0 + + + + + + + + + + + + \ No newline at end of file diff --git a/ApplicationEvents.vb b/ApplicationEvents.vb new file mode 100644 index 0000000..bc254e2 --- /dev/null +++ b/ApplicationEvents.vb @@ -0,0 +1,10 @@ +Namespace My + ' Für MyApplication sind folgende Ereignisse verfügbar: + ' Startup: Wird beim Starten der Anwendung noch vor dem Erstellen des Startformulars ausgelöst. + ' Shutdown: Wird nach dem Schließen aller Anwendungsformulare ausgelöst. Dieses Ereignis wird nicht ausgelöst, wenn die Anwendung mit einem Fehler beendet wird. + ' UnhandledException: Wird bei einem Ausnahmefehler ausgelöst. + ' StartupNextInstance: Wird beim Starten einer Einzelinstanzanwendung ausgelöst, wenn die Anwendung bereits aktiv ist. + ' NetworkAvailabilityChanged: Wird beim Herstellen oder Trennen der Netzwerkverbindung ausgelöst. + Partial Friend Class MyApplication + End Class +End Namespace diff --git a/DVAG - Mailverteiler.sln b/DVAG - Mailverteiler.sln new file mode 100644 index 0000000..72ab73b --- /dev/null +++ b/DVAG - Mailverteiler.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32126.315 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DVAG - Mailverteiler", "DVAG - Mailverteiler.vbproj", "{A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}" +EndProject +Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "DVAG - Mailingverteiler", "..\DVAG - Mailingverteiler\DVAG - Mailingverteiler.vdproj", "{CA2A913C-DD5C-487D-AFCF-BA46D29FB230}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}.Debug|x64.ActiveCfg = Debug|x64 + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}.Debug|x64.Build.0 = Debug|x64 + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}.Release|Any CPU.Build.0 = Release|Any CPU + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}.Release|x64.ActiveCfg = Release|x64 + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6}.Release|x64.Build.0 = Release|x64 + {CA2A913C-DD5C-487D-AFCF-BA46D29FB230}.Debug|Any CPU.ActiveCfg = Debug + {CA2A913C-DD5C-487D-AFCF-BA46D29FB230}.Debug|x64.ActiveCfg = Debug + {CA2A913C-DD5C-487D-AFCF-BA46D29FB230}.Debug|x64.Build.0 = Debug + {CA2A913C-DD5C-487D-AFCF-BA46D29FB230}.Release|Any CPU.ActiveCfg = Release + {CA2A913C-DD5C-487D-AFCF-BA46D29FB230}.Release|x64.ActiveCfg = Release + {CA2A913C-DD5C-487D-AFCF-BA46D29FB230}.Release|x64.Build.0 = Release + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9C88E75E-8783-4E1D-8F30-EAF19BB97F22} + EndGlobalSection +EndGlobal diff --git a/DVAG - Mailverteiler.vbproj b/DVAG - Mailverteiler.vbproj new file mode 100644 index 0000000..aba7f59 --- /dev/null +++ b/DVAG - Mailverteiler.vbproj @@ -0,0 +1,227 @@ + + + + + Debug + AnyCPU + {A8E0FF7C-6740-42D6-90F3-D8109B45F6F6} + WinExe + DVAG___Mailverteiler.My.MyApplication + DVAG___Mailverteiler + DVAG - Mailverteiler + 512 + WindowsForms + v4.7.2 + true + true + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.1.2.%2a + false + true + + + AnyCPU + true + full + true + true + bin\Debug\ + DVAG - Mailverteiler.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + bin\Release\ + DVAG - Mailverteiler.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x64\Debug\ + DVAG - Mailverteiler.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + full + x64 + true + + + true + bin\x64\Release\ + DVAG - Mailverteiler.xml + true + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + pdbonly + x64 + true + + + + packages\chilkat-x64.9.5.0.93\lib\net472\ChilkatDotNet47.dll + + + packages\EAGetMail.5.3.0.2\lib\net472\EAGetMail.dll + + + packages\Microsoft.Office.Interop.Outlook.15.0.4797.1003\lib\net20\Microsoft.Office.Interop.Outlook.dll + True + + + False + ..\..\Program Files (x86)\MySQL\MySQL Connector Net 8.0.29\Assemblies\v4.5.2\MySql.Data.dll + + + + packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + + packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + + packages\System.Security.Cryptography.Pkcs.6.0.1\lib\net461\System.Security.Cryptography.Pkcs.dll + + + packages\System.Text.Encoding.CodePages.6.0.0\lib\net461\System.Text.Encoding.CodePages.dll + + + + + + + + + + + + + + + + + + + + + + + + + + Dashboard.vb + + + Form + + + Form + + + mail_auslesen.vb + Form + + + mail_sending.vb + + + Form + + + + True + Application.myapp + True + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Dashboard.vb + + + mail_auslesen.vb + + + mail_sending.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + + False + Microsoft .NET Framework 4.7.2 %28x86 und x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/Dashboard.Designer.vb b/Dashboard.Designer.vb new file mode 100644 index 0000000..fb1070c --- /dev/null +++ b/Dashboard.Designer.vb @@ -0,0 +1,97 @@ + +Partial Class Dashboard + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container() + Me.bt_verarbeiten = New System.Windows.Forms.Button() + Me.bt_einlesen = New System.Windows.Forms.Button() + Me.lb_version = New System.Windows.Forms.Label() + Me.lb_Dienst = New System.Windows.Forms.Label() + Me.Timer_dienst = New System.Windows.Forms.Timer(Me.components) + Me.SuspendLayout() + ' + 'bt_verarbeiten + ' + Me.bt_verarbeiten.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.bt_verarbeiten.Location = New System.Drawing.Point(132, 34) + Me.bt_verarbeiten.Name = "bt_verarbeiten" + Me.bt_verarbeiten.Size = New System.Drawing.Size(75, 23) + Me.bt_verarbeiten.TabIndex = 0 + Me.bt_verarbeiten.Text = "Verarbeitung" + Me.bt_verarbeiten.UseVisualStyleBackColor = True + ' + 'bt_einlesen + ' + Me.bt_einlesen.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.bt_einlesen.Location = New System.Drawing.Point(44, 34) + Me.bt_einlesen.Name = "bt_einlesen" + Me.bt_einlesen.Size = New System.Drawing.Size(75, 23) + Me.bt_einlesen.TabIndex = 1 + Me.bt_einlesen.Text = "Einlesen" + Me.bt_einlesen.UseVisualStyleBackColor = True + ' + 'lb_version + ' + Me.lb_version.AutoSize = True + Me.lb_version.Location = New System.Drawing.Point(12, 64) + Me.lb_version.Name = "lb_version" + Me.lb_version.Size = New System.Drawing.Size(55, 13) + Me.lb_version.TabIndex = 2 + Me.lb_version.Text = "lb_version" + ' + 'lb_Dienst + ' + Me.lb_Dienst.AutoSize = True + Me.lb_Dienst.Location = New System.Drawing.Point(116, 9) + Me.lb_Dienst.Name = "lb_Dienst" + Me.lb_Dienst.Size = New System.Drawing.Size(51, 13) + Me.lb_Dienst.TabIndex = 3 + Me.lb_Dienst.Text = "lb_Dienst" + ' + 'Timer_dienst + ' + Me.Timer_dienst.Interval = 5000 + ' + 'Dashboard + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(270, 86) + Me.Controls.Add(Me.lb_Dienst) + Me.Controls.Add(Me.lb_version) + Me.Controls.Add(Me.bt_einlesen) + Me.Controls.Add(Me.bt_verarbeiten) + Me.Name = "Dashboard" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Dashboard" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents bt_verarbeiten As Button + Friend WithEvents bt_einlesen As Button + Friend WithEvents lb_version As Label + Friend WithEvents lb_Dienst As Label + Friend WithEvents Timer_dienst As Timer +End Class diff --git a/Dashboard.resx b/Dashboard.resx new file mode 100644 index 0000000..fca2c39 --- /dev/null +++ b/Dashboard.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Dashboard.vb b/Dashboard.vb new file mode 100644 index 0000000..a567b06 --- /dev/null +++ b/Dashboard.vb @@ -0,0 +1,32 @@ +Public Class Dashboard + Private Sub bt_einlesen_Click(sender As Object, e As EventArgs) Handles bt_einlesen.Click + mail_auslesen.Show() + Me.Hide() + End Sub + + Private Sub bt_verarbeiten_Click(sender As Object, e As EventArgs) Handles bt_verarbeiten.Click + mail_sending.Show() + Me.Hide() + + End Sub + + Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing + If MessageBox.Show("Schließen?", "Close", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then + e.Cancel = True + End If + End Sub + + Private Sub Dashboard_Load(sender As Object, e As EventArgs) Handles MyBase.Load + lb_version.Text = My.Application.Info.Version.ToString + Timer_dienst.Start() + End Sub + + Private Sub Timer_dienst_Tick(sender As Object, e As EventArgs) Handles Timer_dienst.Tick + If My.Settings.mail_auslesen = "0" Then + lb_Dienst.Text = "Dienst angehalten" + Else + lb_Dienst.Text = "Dienst wird ausgeführt" + End If + End Sub + +End Class \ No newline at end of file diff --git a/My Project/Application.Designer.vb b/My Project/Application.Designer.vb new file mode 100644 index 0000000..f7df35a --- /dev/null +++ b/My Project/Application.Designer.vb @@ -0,0 +1,38 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten + ' oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer. + ' (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im + ' Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = false + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.DVAG___Mailverteiler.Dashboard + End Sub + End Class +End Namespace diff --git a/My Project/Application.myapp b/My Project/Application.myapp new file mode 100644 index 0000000..e870074 --- /dev/null +++ b/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Dashboard + false + 0 + true + 0 + false + \ No newline at end of file diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..ba401ac --- /dev/null +++ b/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID wird für die typelib-ID verwendet, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' indem Sie "*" wie unten gezeigt eingeben: +' + + + diff --git a/My Project/Resources.Designer.vb b/My Project/Resources.Designer.vb new file mode 100644 index 0000000..326a5c7 --- /dev/null +++ b/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DVAG___Mailverteiler.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/My Project/Resources.resx b/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/My Project/Settings.Designer.vb b/My Project/Settings.Designer.vb new file mode 100644 index 0000000..2fa764a --- /dev/null +++ b/My Project/Settings.Designer.vb @@ -0,0 +1,96 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public Property mail_auslesen() As String + Get + Return CType(Me("mail_auslesen"),String) + End Get + Set + Me("mail_auslesen") = value + End Set + End Property + + _ + Public Property Outlookfolder() As Global.System.Collections.Specialized.StringCollection + Get + Return CType(Me("Outlookfolder"),Global.System.Collections.Specialized.StringCollection) + End Get + Set + Me("Outlookfolder") = value + End Set + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.DVAG___Mailverteiler.My.MySettings + Get + Return Global.DVAG___Mailverteiler.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/My Project/Settings.settings b/My Project/Settings.settings new file mode 100644 index 0000000..949e7d9 --- /dev/null +++ b/My Project/Settings.settings @@ -0,0 +1,12 @@ + + + + + + 0 + + + + + + \ No newline at end of file diff --git a/mail_auslesen.Designer.vb b/mail_auslesen.Designer.vb new file mode 100644 index 0000000..fbd86ac --- /dev/null +++ b/mail_auslesen.Designer.vb @@ -0,0 +1,202 @@ + +Partial Class mail_auslesen + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container() + Me.bt_start = New System.Windows.Forms.Button() + Me.rtb_mail_body = New System.Windows.Forms.RichTextBox() + Me.tb_betreff = New System.Windows.Forms.TextBox() + Me.Label1 = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.Label3 = New System.Windows.Forms.Label() + Me.tb_an = New System.Windows.Forms.TextBox() + Me.Label4 = New System.Windows.Forms.Label() + Me.tb_von = New System.Windows.Forms.TextBox() + Me.lb_id = New System.Windows.Forms.Label() + Me.bt_stop = New System.Windows.Forms.Button() + Me.lb_mailing_ohne_freigabe = New System.Windows.Forms.Label() + Me.Timer_mail_auslesen = New System.Windows.Forms.Timer(Me.components) + Me.Button1 = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'bt_start + ' + Me.bt_start.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.bt_start.Location = New System.Drawing.Point(392, 675) + Me.bt_start.Name = "bt_start" + Me.bt_start.Size = New System.Drawing.Size(75, 23) + Me.bt_start.TabIndex = 0 + Me.bt_start.Text = "Start" + Me.bt_start.UseVisualStyleBackColor = True + ' + 'rtb_mail_body + ' + Me.rtb_mail_body.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.rtb_mail_body.Location = New System.Drawing.Point(12, 141) + Me.rtb_mail_body.Name = "rtb_mail_body" + Me.rtb_mail_body.Size = New System.Drawing.Size(1000, 529) + Me.rtb_mail_body.TabIndex = 1 + Me.rtb_mail_body.Text = "" + ' + 'tb_betreff + ' + Me.tb_betreff.Location = New System.Drawing.Point(59, 92) + Me.tb_betreff.Name = "tb_betreff" + Me.tb_betreff.Size = New System.Drawing.Size(953, 20) + Me.tb_betreff.TabIndex = 2 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(12, 95) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(41, 13) + Me.Label1.TabIndex = 3 + Me.Label1.Text = "Betreff:" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(12, 125) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(53, 13) + Me.Label2.TabIndex = 4 + Me.Label2.Text = "Message:" + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(12, 69) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(23, 13) + Me.Label3.TabIndex = 6 + Me.Label3.Text = "An:" + ' + 'tb_an + ' + Me.tb_an.Location = New System.Drawing.Point(59, 66) + Me.tb_an.Name = "tb_an" + Me.tb_an.Size = New System.Drawing.Size(953, 20) + Me.tb_an.TabIndex = 5 + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(12, 43) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(29, 13) + Me.Label4.TabIndex = 8 + Me.Label4.Text = "Von:" + ' + 'tb_von + ' + Me.tb_von.Location = New System.Drawing.Point(59, 40) + Me.tb_von.Name = "tb_von" + Me.tb_von.Size = New System.Drawing.Size(953, 20) + Me.tb_von.TabIndex = 7 + ' + 'lb_id + ' + Me.lb_id.AutoSize = True + Me.lb_id.Location = New System.Drawing.Point(973, 9) + Me.lb_id.Name = "lb_id" + Me.lb_id.Size = New System.Drawing.Size(29, 13) + Me.lb_id.TabIndex = 9 + Me.lb_id.Text = "lb_id" + ' + 'bt_stop + ' + Me.bt_stop.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.bt_stop.Location = New System.Drawing.Point(500, 675) + Me.bt_stop.Name = "bt_stop" + Me.bt_stop.Size = New System.Drawing.Size(75, 23) + Me.bt_stop.TabIndex = 10 + Me.bt_stop.Text = "Stop" + Me.bt_stop.UseVisualStyleBackColor = True + ' + 'lb_mailing_ohne_freigabe + ' + Me.lb_mailing_ohne_freigabe.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.lb_mailing_ohne_freigabe.AutoSize = True + Me.lb_mailing_ohne_freigabe.Location = New System.Drawing.Point(989, 689) + Me.lb_mailing_ohne_freigabe.Name = "lb_mailing_ohne_freigabe" + Me.lb_mailing_ohne_freigabe.Size = New System.Drawing.Size(127, 13) + Me.lb_mailing_ohne_freigabe.TabIndex = 11 + Me.lb_mailing_ohne_freigabe.Text = "lb_mailing_ohne_freigabe" + ' + 'Timer_mail_auslesen + ' + Me.Timer_mail_auslesen.Interval = 5000 + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(15, 675) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(75, 23) + Me.Button1.TabIndex = 12 + Me.Button1.Text = "Test" + Me.Button1.UseVisualStyleBackColor = True + ' + 'mail_auslesen + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(1024, 711) + Me.Controls.Add(Me.Button1) + Me.Controls.Add(Me.lb_mailing_ohne_freigabe) + Me.Controls.Add(Me.bt_stop) + Me.Controls.Add(Me.lb_id) + Me.Controls.Add(Me.Label4) + Me.Controls.Add(Me.tb_von) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.tb_an) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.tb_betreff) + Me.Controls.Add(Me.rtb_mail_body) + Me.Controls.Add(Me.bt_start) + Me.Name = "mail_auslesen" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Form1" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents bt_start As Button + Friend WithEvents rtb_mail_body As RichTextBox + Friend WithEvents tb_betreff As TextBox + Friend WithEvents Label1 As Label + Friend WithEvents Label2 As Label + Friend WithEvents Label3 As Label + Friend WithEvents tb_an As TextBox + Friend WithEvents Label4 As Label + Friend WithEvents tb_von As TextBox + Friend WithEvents lb_id As Label + Friend WithEvents bt_stop As Button + Friend WithEvents lb_mailing_ohne_freigabe As Label + Friend WithEvents Timer_mail_auslesen As Timer + Friend WithEvents Button1 As Button +End Class diff --git a/mail_auslesen.resx b/mail_auslesen.resx new file mode 100644 index 0000000..0818891 --- /dev/null +++ b/mail_auslesen.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/mail_auslesen.vb b/mail_auslesen.vb new file mode 100644 index 0000000..1db7673 --- /dev/null +++ b/mail_auslesen.vb @@ -0,0 +1,242 @@ +Option Explicit On +'Imports Microsoft.Office.Interop.Outlook +Imports MySql.Data.MySqlClient +Imports System.Globalization +Imports System.Text +Imports System.IO +Imports EAGetMail +Imports Chilkat + + +Public Class mail_auslesen + + + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles bt_start.Click + + Timer_mail_auslesen.Start() + My.Settings.mail_auslesen = "1" + + End Sub + + + + Function _generateFileName(ByVal sequence As Integer) As String + Dim currentDateTime As DateTime = DateTime.Now + Return String.Format("{0}-{1:000}-{2:000}.eml", + currentDateTime.ToString("yyyyMMddHHmmss", New CultureInfo("en-US")), + currentDateTime.Millisecond, + sequence) + End Function + + + Public Sub einlesen() + System.Windows.Forms.Application.DoEvents() + Timer_mail_auslesen.Stop() + + + Dim connStr As String = "server=localhost;user=root;database=dvag_mailing;port=3306;password=;charset=utf8;" + Dim conn As New MySqlConnection(connStr) + Dim sqlcmd As New MySqlCommand + Dim dr + Dim dw + Dim mailing_ohne_freigabe + + Dim strFile As String + Dim strFolderpath As String + + Dim imap As New Chilkat.Imap + + ' Connect to an IMAP server. + ' Use TLS + imap.Ssl = False + imap.Port = 150 + Dim success As Boolean = imap.Connect("127.0.0.1") + If (success <> True) Then + Debug.WriteLine(imap.LastErrorText) + Exit Sub + End If + + + ' Login + success = imap.Login("vorstand@mailing.geographie-dvag.de", "0!07N8,#nvLK6LiG^+PX") + If (success <> True) Then + Debug.WriteLine(imap.LastErrorText) + Exit Sub + End If + + + ' Select an IMAP mailbox + success = imap.SelectMailbox("Inbox") + If (success <> True) Then + Debug.WriteLine(imap.LastErrorText) + Exit Sub + End If + + + + Dim messageSet As Chilkat.MessageSet + ' We can choose to fetch UIDs or sequence numbers. + Dim fetchUids As Boolean = True + ' Get the message IDs of all the emails in the mailbox + messageSet = imap.Search("UNSEEN", fetchUids) + If (imap.LastMethodSuccess = False) Then + Debug.WriteLine(imap.LastErrorText) + Exit Sub + End If + + + ' Fetch the emails into a bundle object: + Dim bundle As Chilkat.EmailBundle + bundle = imap.FetchBundle(messageSet) + If (imap.LastMethodSuccess = False) Then + + Debug.WriteLine(imap.LastErrorText) + Exit Sub + End If + + + ' Loop over the bundle and display the FROM and SUBJECT of each. + Dim i As Integer = 0 + Dim numEmails As Integer = bundle.MessageCount + While i < numEmails + + + + ' ID Auslesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT MAX(id) FROM data", conn) + dr = sqlcmd.ExecuteScalar() + 'MsgBox(dr) + lb_id.Text = dr + 1 + conn.Close() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + ' Ordner anlegen + Try + System.IO.Directory.CreateDirectory("C:\DVAG\Mailing\" & lb_id.Text) + strFolderpath = "C:\DVAG\Mailing\" & lb_id.Text & "\" + Catch ex As System.Exception + + End Try + + + + Dim email As Chilkat.Email = bundle.GetEmail(i) + 'Debug.WriteLine(email.FromAddress) + 'Debug.WriteLine(email.GetToAddr(i)) + 'Debug.WriteLine(email.Subject) + 'Debug.WriteLine(email.Body) + 'Debug.WriteLine("--") + + tb_von.Text = (email.FromAddress) + tb_an.Text = (email.GetToAddr("0")) + + tb_betreff.Text = (email.Subject) + rtb_mail_body.Text = (email.Body) + + rtb_mail_body.Text = rtb_mail_body.Text.Replace("'", "''") + + + + 'Attachment speichern + + email.SaveAllAttachments(strFolderpath) + + + 'Zugriff abfragen + Try + + conn.Open() + sqlcmd = New MySqlCommand("select * from zugriff where mail = '" & tb_von.Text & "' and sender_mail = '" & tb_an.Text & "'", conn) + + mailing_ohne_freigabe = sqlcmd.ExecuteScalar() + lb_mailing_ohne_freigabe.Text = mailing_ohne_freigabe + conn.Close() + Catch ex As System.Exception + + End Try + + + + + If lb_mailing_ohne_freigabe.Text = "" Then + lb_mailing_ohne_freigabe.Text = "0" + Else + lb_mailing_ohne_freigabe.Text = "1" + End If + + + + + ' Daten in DB speichern + conn.Open() + sqlcmd = New MySqlCommand("insert into `data` (`ID`, `from`, `to`, `subject`, `text`, `send`, `mailing_ohne_freigabe`) values ('" & lb_id.Text & "','" & tb_von.Text & "','" & tb_an.Text & "','" & tb_betreff.Text & "','" & rtb_mail_body.Text & "', '0','" & lb_mailing_ohne_freigabe.Text & "' )", conn) + + dw = sqlcmd.ExecuteScalar() + conn.Close() + + + + success = imap.SetFlags(messageSet, "SEEN", 1) + + + ' Disconnect from the IMAP server. + success = imap.Disconnect() + + i = i + 1 + + + 'Felder leeren + tb_von.Text = "" + tb_an.Text = "" + tb_betreff.Text = "" + rtb_mail_body.Text = "" + lb_id.Text = "" + + + End While + + mail_sending.bt_start.PerformClick() + + + + End Sub + + + + Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing + Dashboard.Show() + Me.Hide() + + End Sub + + Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles bt_stop.Click + + Timer_mail_auslesen.Stop() + My.Settings.mail_auslesen = "0" + End Sub + + + Public Shared Function Middle(str As String, startchar As String, endchar As String) As String + Dim strStart As String = str.IndexOf(startchar) + 1 + Dim strEnd As Integer = str.LastIndexOf(endchar) + Return str.Substring(strStart, strEnd - strStart) + ' MsgBox(Middle(Str1, " To: < ", "test.com>")) + End Function + + Private Sub Timer_mail_auslesen_Tick(sender As Object, e As EventArgs) Handles Timer_mail_auslesen.Tick + + einlesen() + End Sub + + Private Sub Button1_Click_2(sender As Object, e As EventArgs) Handles Button1.Click + + + einlesen() + End Sub +End Class + + diff --git a/mail_sending.Designer.vb b/mail_sending.Designer.vb new file mode 100644 index 0000000..b4dffb9 --- /dev/null +++ b/mail_sending.Designer.vb @@ -0,0 +1,282 @@ + +Partial Class mail_sending + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + + Private Sub InitializeComponent() + Me.rtb_mail_body = New System.Windows.Forms.RichTextBox() + Me.bt_start = New System.Windows.Forms.Button() + Me.lb_id = New System.Windows.Forms.Label() + Me.Label4 = New System.Windows.Forms.Label() + Me.tb_von = New System.Windows.Forms.TextBox() + Me.Label3 = New System.Windows.Forms.Label() + Me.tb_an = New System.Windows.Forms.TextBox() + Me.Label2 = New System.Windows.Forms.Label() + Me.Label1 = New System.Windows.Forms.Label() + Me.tb_betreff = New System.Windows.Forms.TextBox() + Me.GroupBox1 = New System.Windows.Forms.GroupBox() + Me.tb_sender_name = New System.Windows.Forms.TextBox() + Me.Label9 = New System.Windows.Forms.Label() + Me.Label8 = New System.Windows.Forms.Label() + Me.rtb_log = New System.Windows.Forms.RichTextBox() + Me.Label7 = New System.Windows.Forms.Label() + Me.rtb_empfaengergruppe = New System.Windows.Forms.RichTextBox() + Me.tb_sender_mail = New System.Windows.Forms.TextBox() + Me.tb_ak_gruppe = New System.Windows.Forms.TextBox() + Me.Label6 = New System.Windows.Forms.Label() + Me.Label5 = New System.Windows.Forms.Label() + Me.GroupBox1.SuspendLayout() + Me.SuspendLayout() + ' + 'rtb_mail_body + ' + Me.rtb_mail_body.Location = New System.Drawing.Point(12, 517) + Me.rtb_mail_body.Name = "rtb_mail_body" + Me.rtb_mail_body.Size = New System.Drawing.Size(897, 179) + Me.rtb_mail_body.TabIndex = 0 + Me.rtb_mail_body.Text = "" + ' + 'bt_start + ' + Me.bt_start.Location = New System.Drawing.Point(12, 702) + Me.bt_start.Name = "bt_start" + Me.bt_start.Size = New System.Drawing.Size(75, 23) + Me.bt_start.TabIndex = 1 + Me.bt_start.Text = "Start" + Me.bt_start.UseVisualStyleBackColor = True + ' + 'lb_id + ' + Me.lb_id.AutoSize = True + Me.lb_id.Location = New System.Drawing.Point(880, 9) + Me.lb_id.Name = "lb_id" + Me.lb_id.Size = New System.Drawing.Size(29, 13) + Me.lb_id.TabIndex = 2 + Me.lb_id.Text = "lb_id" + ' + 'Label4 + ' + Me.Label4.AutoSize = True + Me.Label4.Location = New System.Drawing.Point(12, 413) + Me.Label4.Name = "Label4" + Me.Label4.Size = New System.Drawing.Size(29, 13) + Me.Label4.TabIndex = 15 + Me.Label4.Text = "Von:" + ' + 'tb_von + ' + Me.tb_von.Location = New System.Drawing.Point(81, 410) + Me.tb_von.Name = "tb_von" + Me.tb_von.Size = New System.Drawing.Size(828, 20) + Me.tb_von.TabIndex = 14 + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(12, 439) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(23, 13) + Me.Label3.TabIndex = 13 + Me.Label3.Text = "An:" + ' + 'tb_an + ' + Me.tb_an.Location = New System.Drawing.Point(81, 436) + Me.tb_an.Name = "tb_an" + Me.tb_an.Size = New System.Drawing.Size(828, 20) + Me.tb_an.TabIndex = 12 + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(12, 495) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(53, 13) + Me.Label2.TabIndex = 11 + Me.Label2.Text = "Message:" + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(12, 465) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(41, 13) + Me.Label1.TabIndex = 10 + Me.Label1.Text = "Betreff:" + ' + 'tb_betreff + ' + Me.tb_betreff.Location = New System.Drawing.Point(81, 462) + Me.tb_betreff.Name = "tb_betreff" + Me.tb_betreff.Size = New System.Drawing.Size(828, 20) + Me.tb_betreff.TabIndex = 9 + ' + 'GroupBox1 + ' + Me.GroupBox1.Controls.Add(Me.tb_sender_name) + Me.GroupBox1.Controls.Add(Me.Label9) + Me.GroupBox1.Controls.Add(Me.Label8) + Me.GroupBox1.Controls.Add(Me.rtb_log) + Me.GroupBox1.Controls.Add(Me.Label7) + Me.GroupBox1.Controls.Add(Me.rtb_empfaengergruppe) + Me.GroupBox1.Controls.Add(Me.tb_sender_mail) + Me.GroupBox1.Controls.Add(Me.tb_ak_gruppe) + Me.GroupBox1.Controls.Add(Me.Label6) + Me.GroupBox1.Controls.Add(Me.Label5) + Me.GroupBox1.Location = New System.Drawing.Point(12, 37) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(897, 351) + Me.GroupBox1.TabIndex = 16 + Me.GroupBox1.TabStop = False + Me.GroupBox1.Text = "DVAG - Daten" + ' + 'tb_sender_name + ' + Me.tb_sender_name.Location = New System.Drawing.Point(69, 77) + Me.tb_sender_name.Name = "tb_sender_name" + Me.tb_sender_name.Size = New System.Drawing.Size(377, 20) + Me.tb_sender_name.TabIndex = 9 + ' + 'Label9 + ' + Me.Label9.AutoSize = True + Me.Label9.Location = New System.Drawing.Point(3, 80) + Me.Label9.Name = "Label9" + Me.Label9.Size = New System.Drawing.Size(64, 13) + Me.Label9.TabIndex = 8 + Me.Label9.Text = "From Name:" + ' + 'Label8 + ' + Me.Label8.AutoSize = True + Me.Label8.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label8.Location = New System.Drawing.Point(654, 21) + Me.Label8.Name = "Label8" + Me.Label8.Size = New System.Drawing.Size(39, 20) + Me.Label8.TabIndex = 7 + Me.Label8.Text = "Log" + ' + 'rtb_log + ' + Me.rtb_log.Location = New System.Drawing.Point(452, 51) + Me.rtb_log.Name = "rtb_log" + Me.rtb_log.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical + Me.rtb_log.Size = New System.Drawing.Size(439, 294) + Me.rtb_log.TabIndex = 6 + Me.rtb_log.Text = "" + ' + 'Label7 + ' + Me.Label7.AutoSize = True + Me.Label7.Location = New System.Drawing.Point(2, 106) + Me.Label7.Name = "Label7" + Me.Label7.Size = New System.Drawing.Size(61, 13) + Me.Label7.TabIndex = 5 + Me.Label7.Text = "Empfänger:" + ' + 'rtb_empfaengergruppe + ' + Me.rtb_empfaengergruppe.Location = New System.Drawing.Point(69, 103) + Me.rtb_empfaengergruppe.Name = "rtb_empfaengergruppe" + Me.rtb_empfaengergruppe.Size = New System.Drawing.Size(377, 242) + Me.rtb_empfaengergruppe.TabIndex = 4 + Me.rtb_empfaengergruppe.Text = "" + ' + 'tb_sender_mail + ' + Me.tb_sender_mail.Location = New System.Drawing.Point(69, 51) + Me.tb_sender_mail.Name = "tb_sender_mail" + Me.tb_sender_mail.Size = New System.Drawing.Size(377, 20) + Me.tb_sender_mail.TabIndex = 3 + ' + 'tb_ak_gruppe + ' + Me.tb_ak_gruppe.Location = New System.Drawing.Point(69, 23) + Me.tb_ak_gruppe.Name = "tb_ak_gruppe" + Me.tb_ak_gruppe.Size = New System.Drawing.Size(377, 20) + Me.tb_ak_gruppe.TabIndex = 2 + ' + 'Label6 + ' + Me.Label6.AutoSize = True + Me.Label6.Location = New System.Drawing.Point(3, 54) + Me.Label6.Name = "Label6" + Me.Label6.Size = New System.Drawing.Size(55, 13) + Me.Label6.TabIndex = 1 + Me.Label6.Text = "Absender:" + ' + 'Label5 + ' + Me.Label5.AutoSize = True + Me.Label5.Location = New System.Drawing.Point(5, 26) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(24, 13) + Me.Label5.TabIndex = 0 + Me.Label5.Text = "AK:" + ' + 'mail_sending + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(921, 737) + Me.Controls.Add(Me.GroupBox1) + Me.Controls.Add(Me.Label4) + Me.Controls.Add(Me.tb_von) + Me.Controls.Add(Me.Label3) + Me.Controls.Add(Me.tb_an) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.tb_betreff) + Me.Controls.Add(Me.lb_id) + Me.Controls.Add(Me.bt_start) + Me.Controls.Add(Me.rtb_mail_body) + Me.Name = "mail_sending" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "mail_sending" + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents rtb_mail_body As RichTextBox + Friend WithEvents bt_start As Button + Friend WithEvents lb_id As Label + Friend WithEvents Label4 As Label + Friend WithEvents tb_von As TextBox + Friend WithEvents Label3 As Label + Friend WithEvents tb_an As TextBox + Friend WithEvents Label2 As Label + Friend WithEvents Label1 As Label + Friend WithEvents tb_betreff As TextBox + Friend WithEvents GroupBox1 As GroupBox + Friend WithEvents Label7 As Label + Friend WithEvents rtb_empfaengergruppe As RichTextBox + Friend WithEvents tb_sender_mail As TextBox + Friend WithEvents tb_ak_gruppe As TextBox + Friend WithEvents Label6 As Label + Friend WithEvents Label5 As Label + Friend WithEvents Label8 As Label + Friend WithEvents rtb_log As RichTextBox + Friend WithEvents tb_sender_name As TextBox + Friend WithEvents Label9 As Label +End Class diff --git a/mail_sending.resx b/mail_sending.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/mail_sending.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/mail_sending.vb b/mail_sending.vb new file mode 100644 index 0000000..1c01619 --- /dev/null +++ b/mail_sending.vb @@ -0,0 +1,370 @@ +Imports MySql.Data.MySqlClient +Imports System.Net.Mail + +Public Class mail_sending + + Dim connStr As String = "server=localhost;user=root;database=dvag_mailing;port=3306;password=;charset=utf8;" + Dim connstr_dvag As String = "server=localhost;user=root;database=dvag;port=3306;password=;charset=utf8;" + Dim conn As New MySqlConnection(connStr) + Dim conn_dvag As New MySqlConnection(connstr_dvag) + Dim sqlcmd As New MySqlCommand + Dim dr + Dim dw + + + + + Private Sub bt_start_Click(sender As Object, e As EventArgs) Handles bt_start.Click + + + System.Windows.Forms.Application.DoEvents() + + 'ID einlesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT id FROM data where send = 0 and mailing_ohne_freigabe = 1", conn) + dr = sqlcmd.ExecuteScalar() + lb_id.Text = dr + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": ID " & lb_id.Text & " erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + + + If lb_id.Text = "" Then + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Keine Mailings zum verarbeiten gefunden" & vbNewLine + Else + 'von einlesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT `from` FROM data where ID = " & lb_id.Text & "", conn) + dr = sqlcmd.ExecuteScalar() + tb_von.Text = dr + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Mail von erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + 'an einlesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT `to` FROM data where ID = " & lb_id.Text & "", conn) + dr = sqlcmd.ExecuteScalar() + tb_an.Text = dr + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Mail an erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + + 'Betreff einlesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT `subject` FROM data where ID = " & lb_id.Text & "", conn) + dr = sqlcmd.ExecuteScalar() + tb_betreff.Text = dr + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Betreff erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + 'text einlesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT `text` FROM data where ID = " & lb_id.Text & "", conn) + dr = sqlcmd.ExecuteScalar() + rtb_mail_body.Text = dr + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Mail Body erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + + + 'AK einlesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT `gruppe` FROM `zugriff` where sender_mail = '" & tb_an.Text & "'", conn) + dr = sqlcmd.ExecuteScalar() + tb_ak_gruppe.Text = dr + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Gruppe erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + 'sender_mail einlesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT `sender_mail` FROM `zugriff` where sender_mail = '" & tb_an.Text & "'", conn) + dr = sqlcmd.ExecuteScalar() + tb_sender_mail.Text = dr + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Sender Mail Adresse erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + 'sender_name einlesen + Try + conn.Open() + sqlcmd = New MySqlCommand("SELECT `sender_name` FROM `zugriff` where sender_mail = '" & tb_an.Text & "'", conn) + dr = sqlcmd.ExecuteScalar() + tb_sender_name.Text = dr + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Sender Name erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + + + If tb_ak_gruppe.Text = "" Then + + ' Mail an geschaeftsstelle + + + + + + + + + + 'MsgBox("Keine Empfänger definiert!") + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Keine Empfänger definiert!" & vbNewLine + Exit Sub + Else + + conn.Open() + + 'Regionalforum + If tb_ak_gruppe.Text Like "Forum" Then + sqlcmd = New MySqlCommand("SELECT `email` FROM `tl_member` where xt_regioforum or xt_moreregio like '%" & tb_ak_gruppe.Text & "%' and DISABLE = ''", conn) + + 'Arbeitskreis + ElseIf tb_ak_gruppe.Text Like "AK" Then + sqlcmd = New MySqlCommand("SELECT `email` FROM `tl_member` where xt_arbeitskre like '%" & tb_ak_gruppe.Text & "%' and DISABLE = ''", conn) + + 'Funktionaere + ElseIf tb_ak_gruppe.Text Like "Funktionäre" Then + sqlcmd = New MySqlCommand("SELECT `email` FROM `funktionaere`", conn) + + 'Vorstand + ElseIf tb_ak_gruppe.Text Like "Vorstand" Then + sqlcmd = New MySqlCommand("SELECT `email` FROM `vorstand`", conn) + + 'Mitglieder + ElseIf tb_ak_gruppe.Text Like "Mitglieder" Then + sqlcmd = New MySqlCommand("select email from newsletter union select email from dvag.tl.member where disable = ''", conn) + + 'Test + ElseIf tb_ak_gruppe.Text Like "Test" Then + sqlcmd = New MySqlCommand("SELECT `email` FROM `test`", conn) + + Else + + + + End If + + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Empfänger SQL gesetzt" & vbNewLine + MsgBox(sqlcmd.ToString) + rtb_log.ScrollToCaret() + Try + + + + Dim DataAdapter As New MySqlDataAdapter + DataAdapter.SelectCommand = sqlcmd + + Dim chemicalInventory As New DataTable() + DataAdapter.Fill(chemicalInventory) + + + For Each row As DataRow In chemicalInventory.Rows + ' MsgBox(row.Item("email")) + dr = (row.Item("email")) + rtb_empfaengergruppe.Text = rtb_empfaengergruppe.Text & dr & vbNewLine + Next + + + Dim last = rtb_empfaengergruppe.Text.LastIndexOf("") + If last > 0 Then + + rtb_empfaengergruppe.Text = rtb_empfaengergruppe.Text.Substring(0, last + 1) + Dim beforelast = rtb_empfaengergruppe.Text.LastIndexOf("") + rtb_empfaengergruppe.Text = rtb_empfaengergruppe.Text.Substring(0, beforelast + 0) + + Else + + 'rtb_empfaengergruppe.Text = "" + + End If + + + + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Empfänger erfolgreich eingelesen" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As Exception + 'MsgBox(ex.ToString) + End Try + + End If + + + If rtb_empfaengergruppe.Text = "" Then rtb_log.Text = rtb_log.Text & DateTime.Now & ": Es wurde keine Mail versendet" & vbNewLine + + + + + + End If + + + + Dim tmp As New System.Text.StringBuilder + For Each line As String In rtb_empfaengergruppe.Lines + If line.Trim.Length > 0 Then tmp.AppendLine(line) + Next + rtb_empfaengergruppe.Text = tmp.ToString + + + System.Windows.Forms.Application.DoEvents() + save_log() + mail_versenden() + save_log() + update_sql_gesendete_mails() + save_log() + felder_leeren() + save_log() + + + + End Sub + + + Public Sub mail_versenden() + System.Windows.Forms.Application.DoEvents() + If rtb_empfaengergruppe.Text = "" Then Exit Sub + + + Dim Msg As New MailMessage + Dim myCredentials As New System.Net.NetworkCredential + myCredentials.UserName = "m.haase" + myCredentials.Password = "Start2013!" + Msg.IsBodyHtml = True + Dim mySmtpsvr As New SmtpClient() + mySmtpsvr.Host = "remote.it-professional.biz" 'bei web.de + mySmtpsvr.Port = 27 + mySmtpsvr.EnableSsl = 0 + mySmtpsvr.UseDefaultCredentials = False + mySmtpsvr.Credentials = myCredentials + Try + 'Msg.From = New MailAddress(tb_sender_mail.Text) + Msg.From = New MailAddress(tb_sender_mail.Text, tb_sender_name.Text) + Dim empfaenger As String = rtb_empfaengergruppe.Text + ' MsgBox(empfaenger) + 'MsgBox(empfaenger.Replace(vbLf, ", ")) + empfaenger = empfaenger.Replace(vbLf, ", ") + 'MsgBox(empfaenger) + empfaenger = (empfaenger.Substring(0, empfaenger.Length - 2)) + 'MsgBox(empfaenger) + Msg.Bcc.Add(empfaenger) + + Msg.Subject = tb_betreff.Text + Msg.Body = rtb_mail_body.Text + + + Try + + + For Each item In My.Computer.FileSystem.GetFiles("C:\DVAG\Mailing\" & lb_id.Text, FileIO.SearchOption.SearchTopLevelOnly, "*.*") + 'MsgBox(item) + Dim myAttch = Msg.Attachments + myAttch.Add(New System.Net.Mail.Attachment(item)) + Next + + Catch ex As System.Exception + MsgBox(Err.Number & ex.Message & ex.StackTrace.ToString) + End Try + + + + + + mySmtpsvr.Send(Msg) + rtb_log.Text = rtb_log.Text & DateTime.Now & ": E-Mail gesendet." & vbNewLine + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Auftrag für die ID " & lb_id.Text & " erfolgreich abgeschlossen." & vbNewLine + Catch ex As Exception + MsgBox(Err.Number & ex.Message & ex.StackTrace.ToString) 'Falls ein Fehler auftritt wird eine MsgBox angezeigt + Exit Sub + End Try + + + End Sub + + + + Public Sub felder_leeren() + System.Windows.Forms.Application.DoEvents() + rtb_empfaengergruppe.Clear() + tb_ak_gruppe.Clear() + tb_sender_mail.Clear() + tb_von.Clear() + tb_an.Clear() + tb_betreff.Clear() + rtb_mail_body.Clear() + lb_id.Text = "" + + If My.Settings.mail_auslesen = "1" Then mail_auslesen.Timer_mail_auslesen.Start() + mail_auslesen.Show() + Me.Hide() + + End Sub + + Public Sub update_sql_gesendete_mails() + System.Windows.Forms.Application.DoEvents() + Try + conn.Open() + sqlcmd = New MySqlCommand("update data set `send` = '1', `verarbeitet_am` = '" & DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") & "' where ID = '" & lb_id.Text & "'", conn) + dr = sqlcmd.ExecuteScalar() + + conn.Close() + rtb_log.Text = rtb_log.Text & DateTime.Now & ": Vorgang als abgeschlossen in der DB markiert" & vbNewLine + rtb_log.ScrollToCaret() + Catch ex As System.Exception + MsgBox(ex.ToString) + End Try + End Sub + + + Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing + System.Windows.Forms.Application.DoEvents() + Dashboard.Show() + Me.Hide() + End Sub + + + + Public Sub save_log() + System.Windows.Forms.Application.DoEvents() + rtb_log.SaveFile("c:\DVAG\" & DateTime.Now = ("HH__dd_MM_yyyy") & "mail_log.txt", RichTextBoxStreamType.PlainText) + End Sub + + +End Class \ No newline at end of file diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..1f5d415 --- /dev/null +++ b/packages.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file