 |
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
|
|
|
|
|

October 18th, 2013, 12:40 AM
|
|
Friend of Wrox
|
|
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
|
|
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?:
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..
|
|

October 18th, 2013, 05:50 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

October 18th, 2013, 10:07 AM
|
|
Friend of Wrox
|
|
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
|
|
Quote:
Originally Posted by Imar
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 < [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 < [email protected]
I am confused about the < 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.
|
|

October 18th, 2013, 02:35 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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 > and < which results in the following code:
from="Your Name < [email protected] >">
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
|
|

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

October 18th, 2013, 08:47 PM
|
|
Friend of Wrox
|
|
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
|
|
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.
|
|

October 20th, 2013, 06:18 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

October 20th, 2013, 09:41 AM
|
|
Friend of Wrox
|
|
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
|
|
Quote:
Originally Posted by Imar
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
:-)
|
|

September 29th, 2014, 04:13 PM
|
|
Authorized User
|
|
Join Date: Sep 2014
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
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?
|
|

September 29th, 2014, 04:27 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Take a look at page 335 for an example on using Gmail.
Do you have the code in your config file?
Imar
|
|
 |
|