Translate

Montag, 4. Mai 2015

Visual Basic.net Mails per SMTP-Server versenden

https://www.vb-paradise.de/index.php/Thread/6931-E-Mail-senden-per-SMTP-Simple-Mail-Transfer-Protocol/
https://msdn.microsoft.com/de-de/library/bb979096.aspx

Dim Message As New MailMessage
        Dim Login As New System.Net.NetworkCredential
        Login.UserName = "andreas@absender.de"
        Login.Password = "Passwort des Absenders"
        Message.IsBodyHtml = False
        Dim SMTPServer As New SmtpClient()
        SMTPServer.Host = "smtp.web.de" 'bei web.de
        SMTPServer.Port = 25
        SMTPServer.UseDefaultCredentials = False
        SMTPServer.Credentials = Login
        Try
            Message.From = New MailAddress("andreas@absender.de")
            Message.To.Add("entchen@empfänger.de")
            Message.Subject = "Betreff"
            Message.Body = "Inhalt"
            SMTPServer.Send(Message)
            MsgBox("E-Mail gesendet.", MsgBoxStyle.Information, Title:="Information")
        Catch ex As Exception
            MsgBox(ex.Message) 'Fehlermeldung ausgeben
        End Try

Keine Kommentare:

Kommentar veröffentlichen