<mailSettings > 元素 (网络设置)<mailSettings> Element (Network Settings)

配置邮件发送选项。Configures mail sending options.

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

语法Syntax

<mailSettings>
  <smtp>...</smtp>  
</mailSettings>

特性和元素Attributes and Elements

下列各节描述了特性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.

特性Attributes

无。None.

子元素Child Elements

特性Attribute 描述Description
<smtp > 元素 (网络设置)<smtp> Element (Network Settings) 配置简单邮件传输协议的选项。Configures Simple Mail Transport Protocol options.

父元素Parent Elements

元素Element 说明Description
<system.Net> 元素(网络设置)<system.Net> Element (Network Settings) 包含指定 .NET Framework 如何连接到网络的设置。Contains settings that specify how the .NET Framework connects to the network.

示例Example

下面的示例指定适当的 SMTP 参数,以使用默认网络凭据发送电子邮件。The following example specifies the appropriate SMTP parameters to send email using the default network credentials.

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

请参阅See also