Sugerir tradução
 
Outras sugestões:

progress indicator
Sem sugestões.
Clique para classificar e enviar comentários
Recolher Tudo/Expandir Tudo Recolher Tudo
Exibir Conteúdo: Lado a LadoExibir Conteúdo: Lado a Lado
Este conteúdo foi traduzido automaticamente e pode ser editado pelos membros da comunidade. Para melhorar a qualidade da tradução, clique no link Editar associado à frase que deseja modificar.
.NET Framework Class Library
SmtpMail Class

NOTE: This API is now obsolete.

Provides properties and methods for sending messages using the Collaboration Data Objects for Windows 2000 (CDOSYS) message component. Recommended alternative: System.Net.Mail.

Namespace:  System.Web.Mail
Assembly:  System.Web (in System.Web.dll)
Visual Basic (Declaration)
<ObsoleteAttribute("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class SmtpMail
Visual Basic (Usage)
Dim instance As SmtpMail
C#
[ObsoleteAttribute("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class SmtpMail
Visual C++
[ObsoleteAttribute(L"The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class SmtpMail
JScript
public class SmtpMail

The mail message can be delivered either through the SMTP mail service built into Microsoft Windows 2000 or through an arbitrary SMTP server. Types in the System.Web.Mail namespace can be used from ASP.NET or from any managed application.

If the SmtpServer property is not set, mail is by default queued on a Windows 2000 system, ensuring that the calling program does not block network traffic. If the SmtpMail property is set, the mail is delivered directly to the specified server.

The following example can be compiled to a console application that is used to send email from a command line. If you compile the example to a file named MailMessage.exe, use the executable file to send email as follows:

MailMessage to@contoso.com from@contoso.com test hello
Visual Basic
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
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());
         }
      }
   }
}
J#
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..::.Object
  System.Web.Mail..::.SmtpMail
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 1.1, 1.0
Obsolete (compiler warning) in 3.5
Obsolete (compiler warning) in
Obsolete (compiler warning) in 3.0
Obsolete (compiler warning) in 3.0 SP1
Obsolete (compiler warning) in 2.0
Obsolete (compiler warning) in 2.0 SP1
Biblioteca de classes do .NET Framework
Classe SmtpMail

Observação: essa API é agora obsoleta.

Fornece proprieDadosdes e métodos para enviar mensagens usando o componente de mensagem Collaboration Dadosta Objects para Windows 2000 (CDOSYS). Alternativa recomendada: System.Net.Mail.

Namespace:  System.Web.Mail
Assembly:  System.Web (em System.Web. dll)
Visual Basic (Declaração)
<ObsoleteAttribute("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class SmtpMail
Visual Basic (Uso)
Dim instance As SmtpMail
C#
[ObsoleteAttribute("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class SmtpMail
Visual C++
[ObsoleteAttribute(L"The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class SmtpMail
JScript
public class SmtpMail

A mensagem de email pode ser entregue via o serviço de email SMTP interno do Microsoft Windows 2000 ou via um servidor SMTP arbitrário. Tipos no namespace System.Web.Mail podem ser usados de ASP.NET ou de qualquer aplicativo gerenciado.

Se a propriedade SmtpServer não é definida, email é por padrão enfileirado em um sistema Windows 2000, garantindo que o programa de chamada não Bloquear tráfego de rede. Se a propriedade SmtpMail é definida, o email é entregue diretamente ao servidor especificado.

O exemplo a seguir pode ser compilado para um Aplicativo do Console que é usado para enviar email de uma linha de comando. Se você compilar o exemplo em um arquivo chamado MailMessage.exe, use o arquivo executável para enviar um email da seguinte maneira:

MailMessage to@contoso.com from@contoso.com test hello
Visual Basic
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
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());
         }
      }
   }
}
J#
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..::.Object
  System.Web.Mail..::.SmtpMail
Quaisquer membros público estático (compartilhado no Visual Basic) deste tipo são processos seguros. Quaisquer membros de instância não são garantidos como processos seguros.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

O .NET Framework e .NET Compact Framework não suporte para todas as versões de cada plataforma. Para obter uma lista das versões com suporte, consulte Requisitos de sistema do .NET framework.

.NET Framework

Compatível com: 1.1, 1.0
Obsoleto (aviso do compilador) em 3.5
Obsoleto (aviso do compilador) em
Obsoleto (aviso do compilador) em 3.0
Obsoleto (aviso do compilador) em 3.0 SP1
Obsoleto (aviso do compilador) em 2.0
Obsoleto (aviso do compilador) em 2,0 SP1
Conteúdo da Comunidade   O que é Conteúdo da Comunidade?
Adicionar novo conteúdo RSS  Anotações
Processing
© 2009 Microsoft Corporation. Todos os direitos reservados. Termos de Uso | Marcas Comerciais | Política de Privacidade
Page view tracker