우리는 특정 테스트 이메일 주소로 HTML 문자열의 출력 밖으로을 보내려고에서 이메일을 보낼 때 오류를 지정하고 런타임에이 오류를 발견해야합니다 여기서받는 사람은 ASP.Net
A recipient must be specified.
코드 숨김 파일의 코딩입니다.
Protected Sub EmailTheList()
' Get the rendered HTML.
'-----------------------
Dim SB As New StringBuilder()
Dim SW As New StringWriter(SB)
Dim htmlTW As New HtmlTextWriter(SW)
GridViewSummary.RenderControl(htmlTW)
' Get the HTML into a string.
' This will be used in the body of the email report.
'---------------------------------------------------
Dim dataGridHTML As String = SB.ToString()
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("[email protected]", "myPassword")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
ObjMailMessage = New MailMessage()
Try
ObjMailMessage.From = New MailAddress("[email protected]", "Some text is here.", System.Text.Encoding.UTF8)
ObjMailMessage.Subject = "Test message from Emad"
ObjMailMessage.ReplyToList.Add("[email protected]")
ObjMailMessage.Body = dataGridHTML
ObjMailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
SmtpServer.Send(ObjMailMessage)
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
우리는이 라인에 대한 올바른 구문을 사용하지 않는 의심 :받는 사람에 대한 오류를 일으키는 주소 : 당신은받는 사람을 놓치고
ObjMailMessage.From = ObjMailMessage.ReplyToList.Add("[email protected]")
나는 숨은 목록을 설정 한대로이, 이상한 오류입니다. 나는 "To"만이 정식이라고 생각합니다. – arviman