Code:
Imports System.Net.Mail
Imports System.Net
Public Class Abbrechen
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Control.CheckForIllegalCrossThreadCalls = False
End Sub
Private Sub Senden_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Senden.Click
Senden.Enabled = False
Spam.Enabled = False
Dim sendeThread As New Threading.Thread(AddressOf onesend)
sendeThread.IsBackground = True
sendeThread.Start()
End Sub
Private Sub Spam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Spam.Click
Senden.Enabled = False
Spam.Enabled = False
Dim Spamcount2 As Integer
Try
Spamcount2 = CInt(InputBox("Wie oft soll die Mail gesendet werden?"))
Mailsend(spamcount:=Spamcount2)
Catch oEx As Exception
MsgBox("Fehler: " & oEx.Message.ToString)
End Try
Senden.Enabled = True
Spam.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Delete.Click
Nachricht.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ende.Click
Me.Close()
End Sub
Sub onesend()
Mailsend(spamcount:=1)
End Sub
Public Sub Mailsend(ByRef spamcount As Integer)
Dim Mail As New MailMessage()
With Mail
.From = New MailAddress(Absender.Text)
.Sender = New MailAddress(Absender.Text)
.Subject = Betreff.Text
.Body = Nachricht.Text
End With
For Each e As ListViewItem In ListView2.Items
Mail.Attachments.Add(New Attachment(e.Text))
Next
Dim MailServer As New SmtpClient(Mailhost.Text, CInt(Port.Text))
With MailServer
.Credentials = New NetworkCredential(Absender.Text, Passwort.Text)
.EnableSsl = True
End With
ProgressBar1.Maximum = ListView1.Items.Count
For Each l As ListViewItem In ListView1.Items
Try
Mail.To.Clear()
Mail.To.Add(l.Text)
For i As Integer = 0 To spamcount - 1
MailServer.Send(Mail)
Next
Catch oEx As Exception
MsgBox("Fehler: " + oEx.Message.ToString)
End Try
ProgressBar1.Value += 1
Label10.Text = "Status: " + l.Text & " " & ProgressBar1.Value.ToString & "/" & ListView1.Items.Count.ToString
Next
Label10.Text = "Status:"
ProgressBar1.Value = 0
Senden.Enabled = True
Spam.Enabled = True
End Sub
Private Sub AdresseHinzufügenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdresseHinzufügenToolStripMenuItem.Click
Dim Eingabe As String = InputBox("Adresse:")
If Eingabe = "" Then
Exit Sub
Else
Me.ListView1.Items.Add(Eingabe)
End If
End Sub
Private Sub AdresseLöschenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdresseLöschenToolStripMenuItem.Click
For Each l As ListViewItem In ListView1.SelectedItems
l.Remove()
Next
End Sub
Private Sub ListeSpeichernToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListeSpeichernToolStripMenuItem.Click
Dim path As String = Nothing
Dim SpeicherListe As String = Nothing
Dim sFd As New SaveFileDialog
If sFd.ShowDialog = Windows.Forms.DialogResult.OK Then
path = sFd.FileName
For Each l As ListViewItem In ListView1.Items
SpeicherListe = SpeicherListe & l.Text & vbNewLine
Next
My.Computer.FileSystem.WriteAllText(path, SpeicherListe, False)
End If
End Sub
Private Sub ListeHinzufügenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListeHinzufügenToolStripMenuItem.Click
Dim oFd As New OpenFileDialog
Dim Liste As String
If oFd.ShowDialog = Windows.Forms.DialogResult.OK Then
Liste = My.Computer.FileSystem.ReadAllText(oFd.FileName)
For Each z As String In Split(Liste, vbNewLine)
If z <> "" Then
ListView1.Items.Add(z)
End If
Next
End If
End Sub
Private Sub ListeErsetzenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListeErsetzenToolStripMenuItem.Click
Dim oFd As New OpenFileDialog
Dim Liste As String
If oFd.ShowDialog = Windows.Forms.DialogResult.OK Then
ListView1.Items.Clear()
Liste = My.Computer.FileSystem.ReadAllText(oFd.FileName)
For Each z As String In Split(Liste, vbNewLine)
If z <> "" Then
ListView1.Items.Add(z)
End If
Next
End If
End Sub
Private Sub AnhangHinzufügenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnhangHinzufügenToolStripMenuItem.Click
Dim oFd As New OpenFileDialog
If oFd.ShowDialog = Windows.Forms.DialogResult.OK Then
ListView2.Items.Add(oFd.FileName)
End If
End Sub
Private Sub AnhangEntfehrnenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnhangEntfehrnenToolStripMenuItem.Click
For Each se As ListViewItem In ListView2.SelectedItems
se.Remove()
Next
End Sub
Private Sub TextLadenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextLadenToolStripMenuItem.Click
Dim ofd As New OpenFileDialog
Dim Text As String
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
Text = My.Computer.FileSystem.ReadAllText(ofd.FileName)
Nachricht.Text = Text
End If
End Sub
End Class