SmtpException クラスとは? わかりやすく解説

SmtpException クラス

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

SmtpClient が Send 操作または SendAsync 操作完了できない場合スローされる例外表します

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

<SerializableAttribute> _
Public Class SmtpException
    Inherits Exception
    Implements ISerializable
Dim instance As SmtpException
[SerializableAttribute] 
public class SmtpException : Exception, ISerializable
[SerializableAttribute] 
public ref class SmtpException : public
 Exception, ISerializable
/** @attribute SerializableAttribute() */ 
public class SmtpException extends Exception
 implements ISerializable
SerializableAttribute 
public class SmtpException extends
 Exception implements ISerializable
解説解説
使用例使用例

SmtpException 例外スローされたときにエラー メッセージ表示するコード例次に示します

public static void RetryIfBusy(string
 server)
{
    MailAddress from = new MailAddress("ben@contoso.com");
    MailAddress to = new MailAddress("jane@contoso.com");
    MailMessage message = new MailMessage(from, to);
    // message.Subject = "Using the SmtpClient class.";
    message.Subject = "Using the SmtpClient class.";
    message.Body = @"Using this feature, you can send an
 e-mail message from an application very easily.";
    // Add a carbon copy recipient.
    MailAddress copy = new MailAddress("Notifications@contoso.com");
    message.CC.Add(copy);
    SmtpClient client = new SmtpClient(server);
    // Include credentials if the server requires them.
    client.Credentials = (ICredentialsByHost)CredentialCache.DefaultNetworkCredentials;
    Console.WriteLine("Sending an e-mail message to {0} using
 the SMTP host {1}.",
         to.Address, client.Host);
    try
    {
        client.Send(message);
    }
    catch (SmtpFailedRecipientsException ex)
    {
        for (int i = 0; i < ex.InnerExceptions.Length;
 i++)
        {
            SmtpStatusCode status = ex.InnerExceptions[i].StatusCode;
            if (status == SmtpStatusCode.MailboxBusy ||
                status == SmtpStatusCode.MailboxUnavailable)
            {
                Console.WriteLine("Delivery failed - retrying in
 5 seconds.");
                System.Threading.Thread.Sleep(5000);
                client.Send(message);
            }
            else
            {
                Console.WriteLine("Failed to deliver message to {0}", ex.FailedRecipient[i]);
            }
        }
    }
}
継承階層継承階層
System.Object
   System.Exception
    System.Net.Mail.SmtpException
       System.Net.Mail.SmtpFailedRecipientException
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SmtpException メンバ
System.Net.Mail 名前空間


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

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

辞書ショートカット

すべての辞書の索引

「SmtpException クラス」の関連用語

SmtpException クラスのお隣キーワード
検索ランキング

   

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



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

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

©2024 GRAS Group, Inc.RSS