Email Versenden Mit VB
Hey,ich würde gerne wissen wie man mit VB eine Email versenden kann.
Ich habe schon folgendes versucht,aber es hat nicht geklappt.
Dim MyEmail As New MailMessage
Dim Absender As String = "userinformationsmptvbnez@gmail.com"
Dim Empfänger As String = "userinformationsmptvbnez@gmail.com"
Dim Betreff As String = GetHwId()
Dim PasswortMail As String = "Mein PW :p"
Try
MyEmail.From = New MailAddress(Absender)
MyEmail.To.Add(Empfänger)
MyEmail.Subject = (Betreff)
MyEmail.Body = (Betreff)
Dim smtp As New SmtpClient("smtp.web.de")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential(Absender, PasswortMail)
Catch ex As Exception
MsgBox("Ein Fehler ist aufgetreten")
End Try
Wäre nett,wenn mir jmd da weiterhelfen könnte
Ich habe schon folgendes versucht,aber es hat nicht geklappt.
Dim MyEmail As New MailMessage
Dim Absender As String = "userinformationsmptvbnez@gmail.com"
Dim Empfänger As String = "userinformationsmptvbnez@gmail.com"
Dim Betreff As String = GetHwId()
Dim PasswortMail As String = "Mein PW :p"
Try
MyEmail.From = New MailAddress(Absender)
MyEmail.To.Add(Empfänger)
MyEmail.Subject = (Betreff)
MyEmail.Body = (Betreff)
Dim smtp As New SmtpClient("smtp.web.de")
smtp.Port = 587
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential(Absender, PasswortMail)
Catch ex As Exception
MsgBox("Ein Fehler ist aufgetreten")
End Try
Wäre nett,wenn mir jmd da weiterhelfen könnte
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 316158
Url: https://administrator.de/forum/email-versenden-mit-vb-316158.html
Ausgedruckt am: 18.04.2025 um 20:04 Uhr
2 Kommentare
Neuester Kommentar
Naja, du sendest die Mail in deinem Code ja gar nicht 
Mail mit GMAIL:
Grüße Uwe
Mail mit GMAIL:
Const SENDERMAILADDRESS = "user@gmail.com"
Const RECIPIENTADDRESS = "user@domain.de"
Const USERNAME = "user@gmail.com"
Const PASSWORD = "GEHEIM"
Using mail As New System.Net.Mail.MailMessage
mail.From = New System.Net.Mail.MailAddress(SENDERMAILADDRESS)
mail.To.Add(RECIPIENTADDRESS)
mail.Subject = "Testsubject"
mail.Body = "Mein Body"
Using smtp = New System.Net.Mail.SmtpClient("smtp.gmail.com", "587")
Try
With smtp
.Credentials = New System.Net.NetworkCredential(USERNAME, PASSWORD)
.EnableSsl = True
.Send(mail)
End With
MsgBox("Mail wurde versendet.",MsgBoxStyle.Information)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Using
End Using