<smtp> Element (Network Settings)

 

Configures the delivery format, delivery method, and from address for sending e-mails.

<configuration>
<system.net>
<mailSettings>
<smtp>

  
      <smtp  
  deliveryFormat="format"   
  deliveryMethod="method"   
  from="from address"   
  <specifiedPickupDirectory> … </ specifiedPickupDirectory >  
  <network> … </network>  
/smtp>  

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

Attributes

AttributeDescription
deliveryFormatSpecifies the delivery format for outgoing e-mails. Acceptable values are SevenBit and International.
deliveryMethodSpecifies the delivery method for e-mails. Acceptable values are network, pickupDirectoryFromIis, and specifiedPickupDirectory.
fromSpecifies the from address for outgoing e-mails.

Child Elements

AttributeDescription
specifiedPickupDirectoryConfigures the local directory for a Simple Mail Transport Protocol (SMTP) server.
networkConfigures the network options for an external SMTP server.

Parent Elements

ElementDescription
<mailSettings> Element (Network Settings)Configures mail sending options.

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" deliveryFormat="SevenBit"  from="ben@contoso.com">  
        <network  
          host="localhost"  
          port="25"  
          defaultCredentials="true"  
        />  
      </smtp>  
    </mailSettings>  
  </system.net>  
</configuration>  

System.Net.Configuration.SmtpSection
System.Net.Mail.SmtpClient
SmtpDeliveryFormat
SmtpDeliveryMethod
Network Settings Schema

Show: