Ich habe ein programm geschrieben, das musik abspielen kann, einen Internetzugeng hat...
Bei der E-mail funktion komme ich aber nicht weiter, könnte vielleicht jemand mal bitte den untenstehenden code überprüfen?Er ist mit Visual Basic 2010 Express geschrieben.
Imports System.Net.Mail
Public Class UserControl5
Dim ind1 As Integer = 0
Dim ind As Integer = 0
Dim pw As String = ""
Dim kpwstring As New RichTextBox
Dim adressbuch As New ListBox
Dim adressbuchstring As New RichTextBox
Dim kontostring As New RichTextBox
Dim kontos As New ListBox
Dim adressenint As Integer = 0
Dim adressen As New RichTextBox
Dim smtpserver As String = ""
Dim adressenliste As New ListBox
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ComboBox2.Items.Clear()
Dim laden As New RichTextBox
For k = 0 To kontostring.Lines.Count - 1
kontos.Items.Add(kontostring.Lines(k))
Next
If ComboBox1.Text > "0" Then
pw = kpwstring.Lines(kontos.Items.IndexOf(ComboBox1.Text))
TextBox1.Text = ComboBox1.Text
GroupBox2.Enabled = True
If Val(adressen.Lines(kontos.Items.IndexOf(ComboBox1.Text))) > 0 Then
TextBox5.Text = pw
For j = 0 To Val(adressen.Lines(kontos.Items.IndexOf(ComboBox1.Text))) - 1
If j > 0 Then
ComboBox2.Items.Add(adressbuch.Items.Item(adressbuch.Items.IndexOf("1" & ComboBox1.Text)))
Else
End If
Next
End If
For o = 1 To ComboBox1.Text.Length
If Mid(ComboBox1.Text, o, Len("online")) = "online" Then
smtpserver = "smtp.1und1.de"
ElseIf Mid(ComboBox1.Text, o, Len("t-online")) = "t-online" Then
smtpserver = "smtpmail.t-online.de"
ElseIf Mid(ComboBox1.Text, o, Len("gmx")) = "gmx" Then
smtpserver = "mail.gmx.net"
ElseIf Mid(ComboBox1.Text, o, Len("web")) = "web" Then
smtpserver = "smtp.web.de"
ElseIf Mid(ComboBox1.Text, o, Len("tiscali")) = "tiscali" Then
smtpserver = "smtp.tiscali.de"
ElseIf Mid(ComboBox1.Text, o, Len("yahoo")) = "yahoo" Then
smtpserver = "smtp.mail.yahoo.de"
ElseIf Mid(ComboBox1.Text, o, Len("lycos")) = "lycos" Then
smtpserver = "smtp.lycos.de"
ElseIf Mid(ComboBox1.Text, o, Len("worldonline")) = "worldonline" Then
smtpserver = "smtp.worldonline.de"
ElseIf Mid(ComboBox1.Text, o, Len("epost")) = "epost" Then
smtpserver = "mail.epost.de"
ElseIf Mid(ComboBox1.Text, o, Len("googlemail")) = "googlemail" Then
smtpserver = "smtp.googlemail.com"
ElseIf Mid(ComboBox1.Text, o, Len("o2online")) = "o2online" Then
smtpserver = "mail.o2online.de"
End If
Next
End If
End Sub
Private Sub ComboBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ComboBox1.MouseClick
ComboBox1.Items.Clear()
If My.Settings.Benutzer = "1" Then
adressbuchstring.Text = My.Settings.adressbuch1
kontostring.Text = My.Settings.kontos1
kpwstring.Text = My.Settings.kpw1
adressen.Text = My.Settings.adressen1
ElseIf My.Settings.Benutzer = "2" Then
adressbuchstring.Text = My.Settings.adressbuch2
kontostring.Text = My.Settings.kontos2
kpwstring.Text = My.Settings.kpw2
adressen.Text = My.Settings.adressen2
ElseIf My.Settings.Benutzer = "3" Then
adressbuchstring.Text = My.Settings.adressbuch3
kontostring.Text = My.Settings.kontos3
kpwstring.Text = My.Settings.kpw3
adressen.Text = My.Settings.adressen3
ElseIf My.Settings.Benutzer = "4" Then
adressbuchstring.Text = My.Settings.adressbuch4
kontostring.Text = My.Settings.kontos4
kpwstring.Text = My.Settings.kpw4
adressen.Text = My.Settings.adressen4
End If
For y = 0 To adressbuchstring.Lines.Count - 1
adressbuch.Items.Add(adressbuchstring.Lines(y))
Next
For m = 0 To kontostring.Lines.Count - 1
ComboBox1.Items.Add(kontostring.Lines(m))
Next
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Public Sub sendmail()
Dim emailmassage As MailMessage = New MailMessage
emailmassage.From = New MailAddress(ComboBox1.Text)
emailmassage.To.Add(ComboBox2.Text)
emailmassage.Subject = TextBox3.Text
emailmassage.Body = TextBox4.Text & vbCrLf & vbCrLf & vbCrLf & "VilianViancet/E-mail; " & TimeString.ToString
For i = 0 To (ListBox1.Items.Count - 1)
emailmassage.Attachments.Add(New Attachment(ListBox1.Items(i)))
Next
emailmassage.Priority = MailPriority.Normal
Dim smtp As New SmtpClient(smtpserver)
Dim basicauthentificationinfo As New System.Net.NetworkCredential(ComboBox1.Text, TextBox5.Text)
smtp.Credentials = basicauthentificationinfo
Try
smtp.Send(emailmassage)
MsgBox("Ihre Mail wurde erfolgreich versandt!", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "VilianViancet")
For i = 1 To ComboBox2.Items.Count
If ComboBox2.Text = ComboBox2.Items.Item(i - 1) Then
ind += 1
End If
Next
If ind = 0 Then
x = MsgBox("Wollen Sie " & Chr(147) & ComboBox2.Text & Chr(147) & " zum Adressbuch hinzufügen?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "VilianViancet")
If x = 6 Then
For mich = 0 To adressen.Lines.Count - 1
adressenliste.Items.Add(adressen.Lines(mich))
Next
adressenint = Val(adressen.Lines(kontos.Items.IndexOf(ComboBox1.Text))) + 1
ComboBox2.Items.Add(ComboBox2.Text)
adressbuch.Items.Insert(Val(adressbuch.Items.IndexOf("1" & ComboBox1.Text)) + 1, ComboBox2.Text)
adressenliste.Items.Item(kontos.Items.IndexOf(ComboBox1.Text)) = adressenint.ToString
adressbuchstring.Clear()
For f = 0 To adressbuch.Items.Count - 1
If adressbuchstring.Text = "" Then
adressbuchstring.Text = adressbuch.Items.Item(f)
Else
adressbuchstring.Text = adressbuch.Text & vbNewLine & adressbuch.Items.Item(f)
End If
adressen.Clear()
For dich = 0 To adressenliste.Items.Count - 1
If adressen.Text = "" Then
adressen.Text = adressenliste.Items.Item(dich)
Else
adressen.Text = adressen.Text & vbNewLine & adressenliste.Items.Item(dich)
End If
Next
Next
If My.Settings.Benutzer = "1" Then
My.Settings.adressbuch1 = adressbuchstring.Text
My.Settings.adressen1 = adressen.Text
ElseIf My.Settings.Benutzer = "2" Then
My.Settings.adressbuch2 = adressbuchstring.Text
My.Settings.adressen2 = adressen.Text
ElseIf My.Settings.Benutzer = "3" Then
My.Settings.adressbuch3 = adressbuchstring.Text
My.Settings.adressen3 = adressen.Text
ElseIf My.Settings.Benutzer = "4" Then
My.Settings.adressbuch4 = adressbuchstring.Text
My.Settings.adressen4 = adressen.Text
End If
My.Settings.Save()
End If
End If
Catch ex As Exception
MsgBox("Fehler beim senden!", 0 + 16, "Fehler!")
End Try
ind = 0
End Sub
Private Sub UserControl5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox4.Clear()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
For d = 1 To NumericUpDown1.Value
sendmail()
Next
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox4.Clear()
TextBox5.Clear()
TextBox3.Clear()
ComboBox2.Text = ""
ComboBox2.Items.Clear()
TextBox1.Clear()
ListBox1.Items.Clear()
GroupBox2.Enabled = False
NumericUpDown1.Value = 1
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.CheckFileExists = True Then
ListBox1.Items.Add(OpenFileDialog1.FileName)
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
ListBox1.Items.Clear()
End Sub
Private Sub UserControl5_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
ComboBox2.Items.Remove(ComboBox2.Text)
adressbuch.Items.RemoveAt(adressbuch.Items.IndexOf("1" & ComboBox2.Text) + 1 + ComboBox2.Items.IndexOf(ComboBox2.Text))
adressenint = Val(adressen.Lines(kontos.Items.IndexOf(ComboBox1.Text))) - 1
adressen.Lines(kontos.Items.IndexOf(ComboBox1.Text)) = adressenint.ToString
adressbuchstring.Clear()
For f = 0 To adressbuch.Items.Count - 1
If adressbuchstring.Text = "" Then
adressbuchstring.Text = adressbuch.Items.Item(f)
Else
adressbuchstring.Text = adressbuchstring.Text & vbNewLine & adressbuch.Items.Item(f)
End If
Next
If My.Settings.Benutzer = "1" Then
My.Settings.adressbuch1 = adressbuchstring.Text
My.Settings.adressen1 = adressen.Text
ElseIf My.Settings.Benutzer = "2" Then
My.Settings.adressbuch2 = adressbuchstring.Text
My.Settings.adressen2 = adressen.Text
ElseIf My.Settings.Benutzer = "3" Then
My.Settings.adressbuch3 = adressbuchstring.Text
My.Settings.adressen3 = adressen.Text
ElseIf My.Settings.Benutzer = "4" Then
My.Settings.adressbuch4 = adressbuchstring.Text
My.Settings.adressen4 = adressen.Text
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
kontoinp = InputBox("E-mail", "VilianViancet")
kpwinp = InputBox("Passwort", "VilianViancet")
kontos.Items.Add(kontoinp)
If kpwstring.Text = "" Then
kpwstring.Text = kpwinp
Else
kpwstring.Text = kpwstring.Text & vbNewLine & kpwinp
End If
For f = 0 To kontos.Items.Count - 1
If kontostring.Text = "" Then
kontostring.Text = kontos.Items.Item(f)
Else
kontostring.Text = kontostring.Text & vbNewLine & kontos.Items.Item(f)
End If
Next
If adressen.Text = "" Then
adressen.Text = "0"
Else
adressen.Text = adressen.Text & vbNewLine & "0"
End If
If adressbuchstring.Text = "" Then
adressbuchstring.Text = "1" & kontoinp
Else
adressbuchstring.Text = adressbuchstring.Text & vbNewLine & "1" & kontoinp
End If
If My.Settings.Benutzer = "1" Then
My.Settings.kontos1 = kontostring.Text
My.Settings.adressbuch1 = adressbuchstring.Text
My.Settings.kpw1 = kpwstring.Text
My.Settings.adressen1 = adressen.Text
ElseIf My.Settings.Benutzer = "2" Then
My.Settings.kontos2 = kontostring.Text
My.Settings.adressbuch2 = adressbuchstring.Text
My.Settings.kpw2 = kpwstring.Text
My.Settings.adressen2 = adressen.Text
ElseIf My.Settings.Benutzer = "3" Then
My.Settings.kontos3 = kontostring.Text
My.Settings.adressbuch3 = adressbuchstring.Text
My.Settings.kpw3 = kpwstring.Text
My.Settings.adressen3 = adressen.Text
ElseIf My.Settings.Benutzer = "4" Then
My.Settings.kontos4 = kontostring.Text
My.Settings.adressbuch4 = adressbuchstring.Text
My.Settings.kpw4 = kpwstring.Text
My.Settings.adressen4 = adressen.Text
End If
My.Settings.Save()
ComboBox1.Items.Add(kontoinp)
End Sub
End Class
carl-heinz (3) |