MailSettings code generates VS2005 error in web.config

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

Juan T. Llibre

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

John Kotuby

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

Juan T. Llibre

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top