Klasse Code verwendet: -Senden von E-Mails vb.net
Imports Microsoft.VisualBasic
Imports System.Net.Mail
Public Class SendEmail
Private _Mailto As String = ""
Public Property Mailto() As String
Get
Return _Mailto
End Get
Set(ByVal value As String)
_Mailto = value
End Set
End Property
Private _MailSub As String = ""
Public Property MailSub As String
Get
Return _MailSub
End Get
Set(ByVal value As String)
_MailSub = value
End Set
End Property
Private _MailBody As String = ""
Public Property MailBody As String
Get
Return _MailBody
End Get
Set(ByVal value As String)
_MailBody = value
End Set
End Property
Private _Msg As String = ""
Public ReadOnly Property Msg As String
Get
Return _Msg
End Get
End Property
Public Sub email()
Try
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient("smtp.gmail.com")
mail.From = New MailAddress("[email protected]")
mail.[To].Add(_Mailto)
mail.Subject = _MailSub
mail.Body = _MailBody
' mail.Headers.Add("In-Reply-To", 1)
SmtpServer.Port = 587
SmtpServer.Credentials = New System.Net.NetworkCredential("[email protected]", "password")
SmtpServer.EnableSsl = True
SmtpServer.Send(mail)
_Msg = " Check Your Mail "
Catch ex As Exception
_Msg = ex.Message
End Try
End Sub
End Class
Code innerhalb der Abfrage "-Schaltfläche sub"
Dim objemail As New SendEmail
objemail.Mailto = txtEmail.Text
objemail.email()
LabelEmail.Text = "The email has been sent"
Der angegebene String ist in der Form nicht für eine E-Mail-Adresse erforderlich , und ich habe versucht, vaild email in "mailto" Feld und ive zu entfernen entfernte alles in den Proprities und Feldern und löste noch nicht ,,, Hilfe: D
irgendeine soultion ??
was ist Ihre Frage? – Roger