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

설명

Microsoft Windows 2000에 내장 된 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)

적용 대상