1 out of 4 rated this helpful - Rate this topic

<mailSettings> Element (Network Settings)

Configures mail sending options.

<configuration> Element
  <system.net> Element (Network Settings)
    <mailSettings> Element (Network Settings)
<mailSettings
  <smtp> … </smtp>
/mailsettings>

The following sections describe attributes, child elements, and parent elements.

Attributes

None.

Child Elements

Attribute

Description

<smtp>

Configures Simple Mail Transport Protocol options.

Parent Elements

Element

Description

<system.net>

Contains settings that specify how the .NET Framework connects to the network.

The following code example specifies the appropriate SMTP parameters to send e-mail using the default network credentials.

<configuration>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="network">
        <network
          host="localhost"
          port="25"
          defaultCredentials="true"
        />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
N is for ....
Network has a capital n ... did they even test the example. Silly question
from address required for .NET Framework 4
I had an application that was working under .NET Framework 3.5 and only made one change, i.e. to .NET Framework 4.
This caused an exception which was resolved by specifying the from address.
This worked under .NET Framework 3.5:  <smtp deliveryMethod="Network"> and it failed under .NET Framework 4.
This resolved the problem: <smtp deliveryMethod="Network" from="xxx@yyy.zzz">
(It is interesting that the "from" parameter is not specified as required.)
smtp deliveryMethod must be "Network" (capitalized)
At the time of writing this, the smtp deliveryMethod in the example above was "network" (lower case).  It needs to be "Network" or else it will fail the enumeration constraint.