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

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

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

MailMessage to@contoso.com from@contoso.com test hello  
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());
         }
      }
   }
}
Imports System.Web.Mail
 
Namespace SendMail
   Public Class usage
      Public Sub DisplayUsage()
         ' Display usage instructions in case of error.
         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")
     End Sub
   End Class

   Public Class Start
      '  The main entry point for the application.
      Public Shared Sub Main(ByVal args As String())
         Try
            Try
               Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.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 ehttp As System.Web.HttpException
                  Console.WriteLine("0", ehttp.Message)
                  Console.WriteLine("Here is the full error message")
                  Console.Write("0", ehttp.ToString())
               End Try
            Catch e As IndexOutOfRangeException
               ' Display usage instructions if error in arguments.
               Dim use As usage = New usage()
               use.DisplayUsage()
            End Try
         Catch e As System.Exception
            ' Display text of unknown error.
            Console.WriteLine("Unknown Exception occurred 0", e.Message)
            Console.WriteLine("Here is the Full Error Message")
            Console.WriteLine("0", e.ToString())
         End Try
      End Sub
   End Class
End Namespace

注釈

メール メッセージは、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)

適用対象