|

June 3rd, 2009, 04:47 PM
|
|
Registered User
|
|
Join Date: Jun 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Email set-up problem
In preparing to set up email, I copied the below code straight out of the Beginning ASP 3.5 book (p309). Instead of using the Page_Load event, I used a Button_Click. But other than that, itâs the same code. I also set up my web.config file as instructed.
Yet when I click to run the email, I get an error at the first DIM stmt,
Dim myMessage As MailMessage = New MailMessage()
Error: âThe specified string is not in the form required for an e-mail address."
Has anyone else encountered this problem?
Thanks, Jack Kunkel
code
Imports System.Net.Mail
PartialClass Email1
Inherits System.Web.UI.Page
ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click
Dim myMessage As MailMessage = New MailMessage()
myMessage.Subject = "Test Message"
myMessage.Body = "Hello world!"
myMessage.From = New MailAddress("[email protected]", "Sender Name Here")
myMessage.To.Add(New MailAddress("[email protected]", "Receiver Name Here"))
Dim mySmtpClient As SmtpClient = New SmtpClient()
mySmtpClient.Send(myMessage)
EndSub
EndClass
/code
|