MailMessage コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MailMessage コンストラクタの意味・解説 

MailMessage コンストラクタ (String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

String クラスオブジェクト指定して、MailMessage クラス新しインスタンス初期化します。

名前空間: System.Net.Mail
アセンブリ: System (system.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

fromnull 参照 (Visual Basic では Nothing) です。

または

tonull 参照 (Visual Basic では Nothing) です。

ArgumentException

fromEmpty ("") です。

または

toEmpty ("") です。

FormatException

from または to形式正しくありません。

解説解説
使用例使用例

このコンストラクタ呼び出すコード例次に示します

public static void CreateTestMessage2(string
 server)
{
    string to = "jane@contoso.com";
    string from = "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.";
    SmtpClient client = new SmtpClient(server);
    // Credentials are necessary if the server requires the client 
    // to authenticate before it will send e-mail on the client's behalf.
    client.UseDefaultCredentials = true;
    client.Send(message);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MailMessage クラス
MailMessage メンバ
System.Net.Mail 名前空間

MailMessage コンストラクタ (String, String, String, String)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

MailMessage クラス新しインスタンス初期化します。

名前空間: System.Net.Mail
アセンブリ: System (system.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

fromnull 参照 (Visual Basic では Nothing) です。

または

tonull 参照 (Visual Basic では Nothing) です。

ArgumentException

fromEmpty ("") です。

または

toEmpty ("") です。

FormatException

from または to形式正しくありません。

解説解説
使用例使用例

このコンストラクタ実際に呼び出すコード例次に示します

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);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MailMessage クラス
MailMessage メンバ
System.Net.Mail 名前空間

MailMessage コンストラクタ (MailAddress, MailAddress)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

MailAddress クラスオブジェクト指定して、MailMessage クラス新しインスタンス初期化します。

名前空間: System.Net.Mail
アセンブリ: System (system.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

fromnull 参照 (Visual Basic では Nothing) です。

または

tonull 参照 (Visual Basic では Nothing) です。

FormatException

from または to形式正しくありません。

解説解説
使用例使用例

このコンストラクタ呼び出すコード例次に示します

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);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MailMessage クラス
MailMessage メンバ
System.Net.Mail 名前空間

MailMessage コンストラクタ


MailMessage コンストラクタ


MailMessage コンストラクタ ()



このページでは「.NET Framework クラス ライブラリ リファレンス」からMailMessage コンストラクタを検索した結果を表示しています。
Weblioに収録されているすべての辞書からMailMessage コンストラクタを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からMailMessage コンストラクタ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「MailMessage コンストラクタ」の関連用語

MailMessage コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MailMessage コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS