SmtpMail クラス
アセンブリ: System.Web (system.web.dll 内)
構文
<ObsoleteAttribute("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")> _ Public Class SmtpMail
[ObsoleteAttribute("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")] public class SmtpMail
[ObsoleteAttribute(L"The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")] public ref class SmtpMail
/** @attribute ObsoleteAttribute("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202") */ public class SmtpMail
ObsoleteAttribute("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202") public class SmtpMail
メールは、Microsoft Windows 2000 に組み込まれている SMTP メール サービスまたは任意の SMTP サーバー経由で配信できます。System.Web.Mail 名前空間の型は、ASP.NET と任意のマネージ アプリケーションのどちらからでも使用できます。
SmtpServer プロパティが設定されていない場合、メールは Windows 2000 システム上に既定のキューとして置かれ、呼び出し元のプログラムがネットワーク トラフィックをブロックしないようにします。SmtpMail プロパティが設定されている場合、メールは指定したサーバーに直接配信されます。
次の例をコンパイルすると、コマンド ラインから電子メールを送信できるコンソール アプリケーションを作成できます。この例のコードを MailMessage.exe という名前のファイルにコンパイルした場合は、次のように実行可能ファイルを使用して電子メールを送信できます。
Imports System 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
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()); } } } }
import System.*; import System.Web.Mail.*; 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"); } //DisplayUsage } //Usage class Start { // The main entry point for the application. /** @attribute STAThread() */ public static void main(String[] args) { try { try { MailMessage message = new MailMessage(); message.set_To(args[0]); message.set_From(args[1]); message.set_Subject(args[2]); message.set_Body(args[3]); try { SmtpMail.set_SmtpServer("your mail server name goes here"); SmtpMail.Send(message); } catch (System.Web.HttpException eHttp) { Console.WriteLine("{0}", eHttp.get_Message()); Console.WriteLine("Here is the full error message output"); Console.Write("{0}", eHttp.ToString()); } } catch (IndexOutOfRangeException exp) { Usage use = new Usage(); use.DisplayUsage(); } } catch (System.Exception e) { Console.WriteLine("Unknown Exception occurred {0}", e.get_Message()); Console.WriteLine("Here is the Full Message output"); Console.WriteLine("{0}", e.ToString()); } } //main } //Start()
System.Web.Mail.SmtpMail
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
SmtpMail プロパティ
SmtpMail メソッド
パブリック メソッド
名前 | 説明 | |
---|---|---|
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) | |
Send | オーバーロードされます。 電子メールを送信します。推奨する代替 : System.Net.Mail | |
ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
SmtpMail メンバ
CDOSYS (Collaboration Data Objects for Windows 2000) メッセージ コンポーネントを使用してメッセージを送信するための、プロパティとメソッドを提供します。推奨する代替 : System.Net.Mail
SmtpMail データ型で公開されるメンバを以下の表に示します。
パブリック プロパティ
パブリック メソッド
名前 | 説明 | |
---|---|---|
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) | |
Send | オーバーロードされます。 電子メールを送信します。推奨する代替 : System.Net.Mail | |
ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
名前 | 説明 | |
---|---|---|
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
- SmtpMailのページへのリンク