MailSettings code generates VS2005 error in web.config

  • Thread starter Thread starter John Kotuby
  • Start date Start date
J

John Kotuby

Hi all,
Here's a good one. I'm just trying to set up simple email configuration in
web.config so that I can move my site from my development machine to the
production server. I didn't need to pass an ID and Password to the smtp
server at my office, but the Web server I'm using requires it. So I look
into the online help and find no samples of how to set up that type of
configuration. All examples assume default network credentials.

I find the code below in VS help and copy it into my web.config.

<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network
host="localhost"
port="25"
defaultCredentials="true"
/>
</smtp>
</mailSettings>
</system.net>
</configuration>

Now I get an error on the line <smtp deliveryMethod="network">...
"The deliverymethod attribute is invalid - the value 'network' is invalid
according to its datatype 'NmToken' - the enumeration constraint failed."

It seems that very often even the simplest of tasks can be like pulling
teeth with .NET.
Instead of getting productive work done, I will now be researching another
cryptic VS error message.
What did I do wrong? Does anyone know?

Thanks for any help.
 
Might not be meaningful, but you're missing a parameter ...

<smtp deliveryMethod="network" from="(e-mail address removed)">

You *are* running an ASP.NET 2.0 app, aren't you ?
This only works in ASP.NET 2.0...




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Thanks Juan...
Yes I am using ASP.NET 2.0

But good old Intellisense came to the rescue right after my rant.
The accepted syntax is:
<smtp deliveryMethod="Network">

Isn't that a hoot? Just capitalize Network in it gets accepted.

But during my research I found out that back in May 2006 there was a bug in
System.Net.Mail

If you were hard coding the credentials and used the syntax...

UseDefaultCredentials = false

The ID and Password you coded would be ignored and not sent to the smtp
server.
The fix was to NOT refer to UseDefaultCredentials because it is false by
default.

Maybe this bit of information will help somebody else if the bug has not yet
been fixed.

So to be safe I am leaving...
defaultCredentials="false"
Out of my web.config for the time being.

Thanks again...

P.S. My apologies, I sent the first reply back to you directly and just
corrected my mistake.
 
re:
!> Isn't that a hoot? Just capitalize Network in it gets accepted.

Sometimes it's the little things which trip us.

:-)

re:
!> The fix was to NOT refer to UseDefaultCredentials because it is false by default.

Interesting.

re:
!> Maybe this bit of information will help somebody else if the bug has not yet been fixed.

I'm sure it will.
Thanks for posting the heads-up!





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Back
Top