英語で読む

次の方法で共有


SmtpMail クラス

定義

注意事項

The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202

CDOSYS (Collaboration Data Objects for Windows 2000) メッセージ コンポーネントを使用してメッセージを送信するための、プロパティとメソッドを提供します。 推奨する代替 : System.Net.Mail

C#
public class SmtpMail
C#
[System.Obsolete("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")]
public class SmtpMail
継承
SmtpMail
属性

次の例は、コマンド ラインから電子メールを送信するために使用されるコンソール アプリケーションにコンパイルできます。 この例を MailMessage.exe という名前のファイルにコンパイルする場合は、実行可能ファイルを使用して、次のように電子メールを送信します。

MailMessage to@contoso.com from@contoso.com test hello  
C#
using System;
using System.Web.Mail;
 
namespace SendMail
{
   class usage
   {
      public void DisplayUsage()
      {
         Console.WriteLine("Usage SendMail.exe <to> <from> <subject> <body>");
         Console.WriteLine("<to> the addresses of the email recipients");
         Console.WriteLine("<from> your email address");
         Console.WriteLine("<subject> subject of your email");
         Console.WriteLine("<body> the text of the email");
         Console.WriteLine("Example:");
         Console.WriteLine("SendMail.exe SomeOne@Contoso.com;SomeOther@Contoso.com Me@contoso.com Hi hello");
      }
   }

   class Start
   {
      // The main entry point for the application.
      [STAThread]
      static void Main(string[] args)
      {
         try
         {
            try
            {
               MailMessage Message = new MailMessage();
               Message.To = args[0];
               Message.From = args[1];
               Message.Subject = args[2];
               Message.Body = args[3];

               try
               {
                  SmtpMail.SmtpServer = "your mail server name goes here";
                  SmtpMail.Send(Message);
               }
               catch(System.Web.HttpException ehttp)
               {
                  Console.WriteLine("{0}", ehttp.Message);
                  Console.WriteLine("Here is the full error message output");
                  Console.Write("{0}", ehttp.ToString());
               }
            }
            catch(IndexOutOfRangeException)
            {
               usage use = new usage();
               use.DisplayUsage();
            }
         }
         catch(System.Exception e)
         {
            Console.WriteLine("Unknown Exception occurred {0}", e.Message);
            Console.WriteLine("Here is the Full Message output");
            Console.WriteLine("{0}", e.ToString());
         }
      }
   }
}

注釈

メール メッセージは、Windows 2000 Microsoft組み込みの SMTP メール サービスを介して、または任意の SMTP サーバーを介して配信できます。 名前空間の型は System.Web.Mail 、ASP.NET または任意のマネージド アプリケーションから使用できます。

プロパティが SmtpServer 設定されていない場合、メールは既定で Windows 2000 システムでキューに登録され、呼び出し元のプログラムがネットワーク トラフィックをブロックしないようにします。 プロパティが SmtpMail 設定されている場合、メールは指定されたサーバーに直接配信されます。

プロパティ

SmtpServer
古い.

電子メールを送信するために使用する SMTP メール リレー サーバーの名前を取得または設定します。 推奨する代替 : System.Net.Mail

メソッド

Equals(Object)
古い.

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()
古い.

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()
古い.

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()
古い.

現在の Object の簡易コピーを作成します。

(継承元 Object)
Send(MailMessage)
古い.

MailMessage クラスのプロパティで指定した引数を使用して電子メールを送信します。 推奨する代替 : System.Net.Mail

Send(String, String, String, String)
古い.

指定した送信先パラメーターを使用して、電子メールを送信します。 推奨する代替 : System.Net.Mail

ToString()
古い.

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

製品 バージョン (廃止)
.NET Framework 1.1 (2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1)