SmtpClient コンストラクタ (String, Int32)
アセンブリ: System (system.dll 内)



host パラメータは Host プロパティの値を設定し、port パラメータは Port プロパティの値を設定します。host が null 参照 (Visual Basic では Nothing) か、String.Empty と等しい場合、Host は、アプリケーションまたはコンピュータの構成ファイルの設定を使用して初期化されます。port が 0 の場合、Port は、アプリケーションまたはコンピュータの構成ファイルの設定を使用して初期化されます。Credentials プロパティは、アプリケーションまたはコンピュータの構成ファイルの設定を使用して初期化されます。
アプリケーションの構成ファイルおよびコンピュータの構成ファイルの使用方法の詳細については、「mailSettings 要素 (ネットワーク設定)」を参照してください。SmtpClient のコンストラクタまたはプロパティを使用して情報が指定されている場合、この情報によって構成ファイルの設定がオーバーライドされます。

public static void CreateTestMessage1(string server, int port) { string to = "jane@contoso.com"; string from = "ben@contoso.com"; string subject = "Using the new SMTP client."; string body = @"Using this new feature, you can send an e-mail message from an application very easily."; MailMessage message = new MailMessage(from, to, subject, body); SmtpClient client = new SmtpClient(server, port); // Credentials are necessary if the server requires the client // to authenticate before it will send e-mail on the client's behalf. client.Credentials = CredentialCache.DefaultNetworkCredentials; client.Send(message); }


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SmtpClient コンストラクタ (String)
アセンブリ: System (system.dll 内)


host パラメータは、Host プロパティの値の初期化に使用されます。Credentials プロパティと Port プロパティは、アプリケーションまたはコンピュータの構成ファイルの設定を使用して初期化されます。host が null 参照 (Visual Basic では Nothing) か、String.Empty と等しい場合、Host は、アプリケーションまたはコンピュータの構成ファイルの設定を使用して初期化されます。
アプリケーションの構成ファイルおよびコンピュータの構成ファイルの使用方法の詳細については、「mailSettings 要素 (ネットワーク設定)」を参照してください。SmtpClient のコンストラクタまたはプロパティを使用して情報が指定されている場合、この情報によって構成ファイルの設定がオーバーライドされます。

public static void CreateTimeoutTestMessage(string server) { string to = "jane@contoso.com"; string from = "ben@contoso.com"; string subject = "Using the new SMTP client."; string body = @"Using this new feature, you can send an e-mail message from an application very easily."; MailMessage message = new MailMessage(from, to, subject, body); SmtpClient client = new SmtpClient(server); Console.WriteLine("Changing time out from {0} to 100.", client.Timeout); client.Timeout = 100; // Credentials are necessary if the server requires the client // to authenticate before it will send e-mail on the client's behalf. client.Credentials = CredentialCache.DefaultNetworkCredentials; client.Send(message); }


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SmtpClient コンストラクタ

名前 | 説明 |
---|---|
SmtpClient () | 構成ファイルの設定を使用して SmtpClient クラスの新しいインスタンスを初期化します。 |
SmtpClient (String) | 指定した SMTP サーバーを使用して電子メールを送信する SmtpClient クラスの新しいインスタンスを初期化します。 |
SmtpClient (String, Int32) | 指定した SMTP サーバーとポートを使用して電子メールを送信する SmtpClient クラスのインスタンスを初期化します。 |

SmtpClient コンストラクタ ()
アセンブリ: System (system.dll 内)


このコンストラクタは、アプリケーションまたはコンピュータの構成ファイルの設定を使用して、新しい SmtpClient に対する Host、Credentials、および Port の各プロパティを初期化します。詳細については、「mailSettings 要素 (ネットワーク設定)」を参照してください。

public static void CreateTestMessage3() { MailAddress to = new MailAddress("jane@contoso.com"); MailAddress from = new MailAddress("ben@contoso.com"); MailMessage message = new MailMessage(from, to); message.Subject = "Using the new SMTP client."; message.Body = @"Using this new feature, you can send an e-mail message from an application very easily."; // Use the application or machine configuration to get the // host, port, and credentials. SmtpClient client = new SmtpClient(); Console.WriteLine("Sending an e-mail message to {0} at {1} by using the SMTP host {2}.", to.User, to.Host, client.Host); client.Send(message); }
アプリケーションまたはコンピュータの構成ファイルの <mailSettings> ノードの例については、「mailSettings 要素 (ネットワーク設定)」を参照してください。


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からSmtpClient コンストラクタを検索する場合は、下記のリンクをクリックしてください。

- SmtpClient コンストラクタのページへのリンク