This documentation is archived and is not being maintained.

SmtpMail.SmtpServer Property

Gets or sets the name of the SMTP relay mail server to use to send e-mail messages.

[Visual Basic]
Public Shared Property SmtpServer As String
[C#]
public static string SmtpServer {get; set;}
[C++]
public: __property static String* get_SmtpServer();
public: __property static void set_SmtpServer(String*);
[JScript]
public static function get SmtpServer() : String;
public static function set SmtpServer(String);

Property Value

The name of the e-mail relay server. If SmtpServer is not set, the name of the local SMTP server is used.

Remarks

If your local SMTP server (included with Windows 2000 and Windows Server 2003) is behind a firewall that blocks any direct SMTP traffic (through port 25), you will need to find out if there is a smart host available on your network that is allowed to relay SMTP messages to the Internet.

A smart host is an SMTP server with the permissions to relay outgoing e-mail messages directly to the Internet from internal SMTP servers. A smart host should be able to simultaneously connect to both the internal network and the Internet in order to work as the e-mail gateway.

For information about configuring your local SMTP server, see the articles "Manage Your Company's E-mail with the Windows 2000 SMTP Service" and "Using SMTP for Outgoing Messages" in the MSDN library at http://msdn.microsoft.com.

Example

[Visual Basic] 
' This example assigns the name of the mail relay server on the 
' local network to the SmtpServer property.
SmtpMail.SmtpServer = "RelayServer.Contoso.com"

[C#] 
//This example assigns the name of the mail relay server on the 
//local network to the SmtpServer property.
SmtpMail.SmtpServer = "RelayServer.Contoso.com";

[C++] 
//This example assigns the name of the mail relay server on the
//local network to the SmtpServer property.
SmtpMail::SmtpServer = S"RelayServer.Contoso.com";

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

SmtpMail Class | SmtpMail Members | System.Web.Mail Namespace

Show: