0
我在此代碼指定的字符串不是一個電子郵件地址
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
和異常有問題所要求的形式是:指定的字符串不是在一封所要求的形式郵件地址:任何靈魂?
這段代碼中存在的形式和組成按鈕,文本框被稱爲 「txtemail」 保護小組Send_Click的(BYVAL發件人爲對象,BYVALË作爲System.EventArgs)把手Send.Click 昏暗objemail作爲新SendEmail objemail.Mailto = txtEmail.Text objemail.email() LabelEmail.Text =「電子郵件已發送」 End Sub – 2012-04-09 03:50:32
@Alaahafethburghall:請更新您剛剛發佈的問題。代碼在評論區非常難以閱讀。 – StriplingWarrior 2012-04-09 03:53:40
@Alaahafethburghall:另外,在單擊發送按鈕之前,顯示您在文本框中提供的輸入內容。您是否已經在調試器中逐步瞭解了代碼運行時_MailTo值的值? – StriplingWarrior 2012-04-09 03:57:16