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 2nd, 2008, 10:51 AM
Registered User
 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Email error message

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim myMessage As MailMessage = New MailMessage()

When I use this code (straight from Beginning ASP.Net 3.5) I get the following error message for Dim myMessage As MailMessage = New MailMessage()

"The specified string is not in the form required for an e-mail address."

Help!

Carthalion

Edit: moved to book forum - planoie
 
Old June 2nd, 2008, 11:15 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 Carthalion,

If this is related to the book directly, you're better off posting this in its own forum located here: http://p2p.wrox.com/forum.asp?FORUM_ID=386

Regarding the error: I doubt this is the offending code. The MailMessage class has an empty constructor, so this line of code should compile just fine.

It looks like later code that sets an e-mail address (or the lack thereof) may cause the problem. Can you post the full code example? (Preferably in the book's forum with a reference to this post?)

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old June 2nd, 2008, 12:59 PM
Authorized User
 
Join Date: Apr 2008
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am getting the same error message as stated above in C#. I have included the Code Behind file and the <system.net> section of the web.config file. Thank you for your assistance.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Net.Mail;

public partial class Email : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        MailMessage myMessage = new MailMessage();
        myMessage.Subject = "Test Message";
        myMessage.Body = "Hello world, from Planet Wrox";

        myMessage.From = new MailAddress("[email protected]", "Brian Workinger");
        myMessage.To.Add(new MailAddress("[email protected]", "Brian Workinger"));
        Response.Write(myMessage);
        SmtpClient mySmtpClient = new SmtpClient();
        mySmtpClient.Send(myMessage);
    }
}

<system.net> from web.config file

<system.net>
        <mailSettings>
            <smtp deliveryMethod="Network" from="Brian Workinger &lt;[email protected]&gt;">
                <network host="smtp.Hotmail.com" userName="myUserID" password="myPassword"/>
            </smtp>
        </mailSettings>
    </system.net>
</configuration>

Cheers,

Brian
 
Old June 2nd, 2008, 01:17 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I'm thinking the problem is the 'from' value in the 'smtp' configuration. Have you tried it with just the email address?

-Peter
compiledthoughts.com
 
Old June 2nd, 2008, 01:46 PM
Authorized User
 
Join Date: Apr 2008
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter,

I removed my name from the From in the Smtp section and that did not help but I changed it as follows because I do think I had an error there, however, now I am getting a differnt error message. The modified code and error message are below.

smtp deliveryMethod="Network" from="Brian Workinger&lt;[email protected]&gt;">
                <network host="smtp.Hotmail.com" userName="myUserID" password="myPassword"/>
            </smtp>

and the following error message is returned.

The remote name could not be resolved: 'smtp.Hotmail.com'
 
Old June 2nd, 2008, 03:23 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

That could certainly be a problem. Most system won't allow incoming SMTP mail drops without some authentication criteria being met. You are best off finding out what your ISP mail host is and try that. Usually an ISP will allow "anonymous" mail drops onto their server because it's coming from inside their network (even though you are on a public internet address, it's their address so they can control it). This is how I've done this type of thing. You just have to check your ISP web site for the SMTP settings.

-Peter
compiledthoughts.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
webshop email confirmation message Nick23 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 September 14th, 2007 03:43 PM
Send Message to Email inbaa ASP.NET 1.0 and 1.1 Professional 2 August 28th, 2006 05:45 AM
Embed report into email message. liliarum BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 8th, 2004 01:27 PM
email message with wrong characters marcrock Flash (all versions) 4 February 8th, 2004 05:35 PM





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