Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2009, 04:47 PM
Registered User
 
Join Date: Jun 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
End
Class
/code
 
Old June 4th, 2009, 03:43 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Is this all the code in the page? I just ran your code and it runs fine for me. Also, the error you get doesn't make a lot of sense. When creating a new MailMessage you're not required to enter a from address yet (with the empty constructor you are using) so there's no reason for .NET to check the address there.

Can you provide more details? Where and when do you get this error? What version of VWD / .NET are you running? Can you show us a screen shot or describe a reproducible scenario?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Email problem asif_sharif ASP.NET 1.0 and 1.1 Professional 3 January 11th, 2006 01:37 PM
Complex Set problem pankaj_daga SQL Language 0 November 12th, 2003 08:47 AM
Email Problem Teon ASP.NET 1.0 and 1.1 Basics 1 September 29th, 2003 07:59 AM
record set problem spraveens Classic ASP Databases 6 September 12th, 2003 06:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.