Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB 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 October 18th, 2013, 12:40 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Web.Config SMTP Settings

I am little bit confused here considering the following:

Code:
<mailSettings>
      <smtp>
      <network host="localhost" port="587" userName="[email protected]" password="XXXX" />
    </smtp>

    </mailSettings>
How do I add the To and From part of the mail setting in the smtp node. I was looking at the book I just couldn't quite put it together. I am not sure how that would look like. I don't see a clear example on this in the book.

Thank you :-)
Could I do this maybe?:
Code:
<smtp>
      <network host="localhost" port="587" from="[email protected]" to="[email protected]" userName="[email protected]" password="XXXX" />
    </smtp>
Would that work maybe?
Seeing as how this code is sitting on a remote production server, there is no way I can test this out locally. So before I make changes I want to make sure that I have the right code or I just might crash the application and cause all kinds of headaches galore that I don't want to endure with right now. I guess in a way this becomes a deployment issue and I need to ask someone has a lot more experience of deploying .NET apps than I do, and seeing as how SMTP and deployment are big parts of the book, think that is is a fair question.

Thanks :-)

Last edited by vbboyd; October 18th, 2013 at 12:54 AM..
 
Old October 18th, 2013, 05:50 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can find an example of the from attribute on page 335 in Chapter 9.

The To can't be set in web.config as it relates to individual messages, not to the global settings.

Cheers,

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!
 
Old October 18th, 2013, 10:07 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default

Quote:
Originally Posted by Imar View Post
You can find an example of the from attribute on page 335 in Chapter 9.

The To can't be set in web.config as it relates to individual messages, not to the global settings.

Cheers,

Imar
That is where I am getting confused. Given the following web.config entry
Code:
<mailSettings>
      <smtp>
      <network host="localhost" port="587" userName="[email protected]" password="XXXX" />
    </smtp>

    </mailSettings>
would the <smtp> node look like this?:

<network host="localhost" port="587" from="XXX &lt;[email protected]" userName="[email protected]" password="XXXX" />

Or would it look like this:
<network host="localhost" port="587" from="[email protected]" userName="[email protected]" password="XXXX" />
As I look at page 335 in the book I see:
from="Your Name &lt;[email protected]
I am confused about the &lt part of your SMTP string.

I am confused about the syntax on this SMTP node of which is the correct to use and seeing as how the app is posted to a very remote production server, I have no way of testing it without crashing the application. Which begs another question is there anywhere in the book that talks about remote testing of an application resting on very far away production server that can accessed via the Visual Studio IDE? Is that even possible.
 
Old October 18th, 2013, 02:35 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If you just want to display the e-mail address, simply use:

from="[email protected]"

If you also want to use a display name, the format is:

Display Name <emailaddress>

Since < and > have special meaning, you need to encode them as &gt; and &lt; which results in the following code:

from="Your Name &lt;[email protected] &gt;">

where Your Name is the display name, and [email protected] the e-mail address.

You can try this stuff out locally as well if you're unsure about the syntax.

>> is there anywhere in the book that talks about remote testing of an application resting on very far away production server

I think you've read the whole book about now, so I think you know the answer to that question. Hint: it's No ;-)

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!
 
Old October 18th, 2013, 03:31 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default

I think you've read the whole book about now, so I think you know the answer to that question. Hint: it's No ;-)

Imar[/QUOTE]

Truth be it known, I really haven't read through too much of the appendix sections of the book at all. I thought that it might be there. My bad. Casi Nada Señor, which is Texas for "hardly any guy". That is why I was asking. Thanks for letting me know, that way I wouldn't waste any time looking around for material in the back of the book that does not exist.
 
Old October 18th, 2013, 08:47 PM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default Continued Error message

I made the changes that are in the book and that you recommended and I still get the following error code message

Code:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Unrecognized attribute 'from'. Note that attribute names are case-sensitive.

Source Error: 


Line 53:     <mailSettings>
Line 54:       <smtp>
Line 55:       <network host="localhost" port="587" from="[email protected]" userName="[email protected]" password="ABC123" />
Line 56:     </smtp>
Line 57:
So I don't know what is wrong here. Maybe you can tell me.
 
Old October 20th, 2013, 06:18 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take another look at the error message:

Quote:
Unrecognized attribute 'from'.
And then compare your code with the example on page 335. You added the from attribute to the wrong element.

Cheers,

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!
 
Old October 20th, 2013, 09:41 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default

Quote:
Originally Posted by Imar View Post
Take another look at the error message:


And then compare your code with the example on page 335. You added the from attribute to the wrong element.

Cheers,

Imar
Thanks but I have already taken care of it just this morning and so far it seems to be working just fine.

Prost

:-)
 
Old September 29th, 2014, 04:13 PM
Authorized User
 
Join Date: Sep 2014
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
Default what did you do?

I've had the same problem and I cannot figure out what I am missing. I've gone over the example in book and still nada. Do I need to edit the code anywhere else besides the web.config and contact control?

You can send the email through Gmail while your debugging, correct? Or does the site have to be active to use gmail?

I've edited the web.config file and the contact control.

I'm at work rght now so unfortunately I can't include code that I'm using.

What did you ultimately have to do to use Gmail?
 
Old September 29th, 2014, 04:27 PM
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,

Take a look at page 335 for an example on using Gmail.

Do you have the code in your config file?

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
Blog - Web.Config Settings for Access Database kanzeon4 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 April 5th, 2008 07:46 AM
Web.Config and Settings dsr771 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 August 13th, 2007 12:59 PM
Config of default smtp web server on IIS 5.0 kumarop Classic ASP Components 0 February 20th, 2005 04:22 AM
Web.Config Settings debsoft VS.NET 2002/2003 1 December 11th, 2003 06:06 PM





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