Sugerir traducción
 
Otros han sugerido:

progress indicator
No hay más sugerencias.
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Ver contenido:  en paraleloVer contenido: en paralelo
.NET Framework Class Library
MailAddressCollection Class

Store e-mail addresses that are associated with an e-mail message.

System..::.Object
  System.Collections.ObjectModel..::.Collection<(Of <(MailAddress>)>)
    System.Net.Mail..::.MailAddressCollection

Namespace:  System.Net.Mail
Assembly:  System (in System.dll)
Visual Basic
Public Class MailAddressCollection _
    Inherits Collection(Of MailAddress)
C#
public class MailAddressCollection : Collection<MailAddress>
Visual C++
public ref class MailAddressCollection : public Collection<MailAddress^>
F#
type MailAddressCollection =  
    class
        inherit Collection<MailAddress>
    end

The MailAddressCollection type exposes the following members.

  NameDescription
Public methodMailAddressCollectionInitializes an empty instance of the MailAddressCollection class.
Top
  NameDescription
Public propertyCountGets the number of elements actually contained in the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Public propertyItemGets or sets the element at the specified index. (Inherited from Collection<(Of <(T>)>).)
Protected propertyItemsGets a IList<(Of <(T>)>) wrapper around the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Top
  NameDescription
Public methodAdd(T)Adds an object to the end of the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Public methodAdd(String)Add a list of e-mail addresses to the collection.
Public methodClearRemoves all elements from the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Protected methodClearItemsRemoves all elements from the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Public methodContainsDetermines whether an element is in the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Public methodCopyToCopies the entire Collection<(Of <(T>)>) to a compatible one-dimensional Array, starting at the specified index of the target array. (Inherited from Collection<(Of <(T>)>).)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEnumeratorReturns an enumerator that iterates through the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfSearches for the specified object and returns the zero-based index of the first occurrence within the entire Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Public methodInsertInserts an element into the Collection<(Of <(T>)>) at the specified index. (Inherited from Collection<(Of <(T>)>).)
Protected methodInsertItemInserts an e-mail address into the MailAddressCollection, at the specified location. (Overrides Collection<(Of <(T>)>)..::.InsertItem(Int32, T).)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveRemoves the first occurrence of a specific object from the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Public methodRemoveAtRemoves the element at the specified index of the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Protected methodRemoveItemRemoves the element at the specified index of the Collection<(Of <(T>)>). (Inherited from Collection<(Of <(T>)>).)
Protected methodSetItemReplaces the element at the specified index. (Overrides Collection<(Of <(T>)>)..::.SetItem(Int32, T).)
Public methodToStringReturns a string representation of the e-mail addresses in this MailAddressCollection object. (Overrides Object..::.ToString()()().)
Top
  NameDescription
Explicit interface implemetationPrivate methodICollection..::.CopyToCopies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate propertyICollection<(Of <(T>)>)..::.IsReadOnlyGets a value indicating whether the ICollection<(Of <(T>)>) is read-only. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate propertyICollection..::.IsSynchronizedGets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate propertyICollection..::.SyncRootGets an object that can be used to synchronize access to the ICollection. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate methodIEnumerable..::.GetEnumeratorReturns an enumerator that iterates through a collection. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate methodIList..::.AddAdds an item to the IList. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate methodIList..::.ContainsDetermines whether the IList contains a specific value. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate methodIList..::.IndexOfDetermines the index of a specific item in the IList. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate methodIList..::.InsertInserts an item into the IList at the specified index. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate propertyIList..::.IsFixedSizeGets a value indicating whether the IList has a fixed size. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate propertyIList..::.IsReadOnlyGets a value indicating whether the IList is read-only. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate propertyIList..::.ItemGets or sets the element at the specified index. (Inherited from Collection<(Of <(T>)>).)
Explicit interface implemetationPrivate methodIList..::.RemoveRemoves the first occurrence of a specific object from the IList. (Inherited from Collection<(Of <(T>)>).)
Top

The MailMessage..::.To, MailMessage..::.CC, and MailMessage..::.Bcc properties return instances of this class that are used to hold the respective e-mail addresses.

For details on the mail address formats supported by the MailAddressCollection class, see the MailAddress class.

The following example adds an e-mail address to the MailAddressCollection that is returned by the Bcc property.

C#
        public static void CreateBccTestMessage(string server)
        {
            MailAddress from = new MailAddress("ben@contoso.com", "Ben Miller");
            MailAddress to = new MailAddress("jane@contoso.com", "Jane Clayton");
            MailMessage message = new MailMessage(from, to);
            message.Subject = "Using the SmtpClient class.";
            message.Body = @"Using this feature, you can send an e-mail message from an application very easily.";
            MailAddress bcc = new MailAddress("manager1@contoso.com");
            message.Bcc.Add(bcc);
            SmtpClient client = new SmtpClient(server);
            client.Credentials = CredentialCache.DefaultNetworkCredentials;
            Console.WriteLine("Sending an e-mail message to {0} and {1}.", 
                to.DisplayName, message.Bcc.ToString());
      try {
        client.Send(message);
      }  
      catch (Exception ex) {
        Console.WriteLine("Exception caught in CreateBccTestMessage(): {0}", 
                    ex.ToString() );
        }
      }
Visual C++
   static void CreateBccTestMessage( String^ server )
   {
      MailAddress^ from = gcnew MailAddress( L"ben@contoso.com",L"Ben Miller" );
      MailAddress^ to = gcnew MailAddress( L"jane@contoso.com",L"Jane Clayton" );
      MailMessage^ message = gcnew MailMessage( from,to );
      message->Subject = L"Using the SmtpClient class.";
      message->Body = L"Using this feature, you can send an e-mail message from an application very easily.";
      MailAddress^ bcc = gcnew MailAddress( L"manager1@contoso.com" );
      message->Bcc->Add( bcc );
      SmtpClient^ client = gcnew SmtpClient( server );
      client->Credentials = CredentialCache::DefaultNetworkCredentials;
      Console::WriteLine( L"Sending an e-mail message to {0} and {1}.", to->DisplayName, message->Bcc );
      try
      { 
          client->Send( message );
      }
      catch ( Exception^ ex )
      {
          Console::WriteLine(L"Exception caught in CreateBccTestMessage(): {0}", 
                        ex->ToString() );
      }
      client->~SmtpClient();
   }


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Biblioteca de clases de .NET Framework
MailAddressCollection (Clase)

Almacena direcciones de correo electrónico asociadas a un mensaje de correo electrónico.

System..::.Object
  System.Collections.ObjectModel..::.Collection<(Of <(MailAddress>)>)
    System.Net.Mail..::.MailAddressCollection

Espacio de nombres:  System.Net.Mail
Ensamblado:  System (en System.dll)
Visual Basic
Public Class MailAddressCollection _
    Inherits Collection(Of MailAddress)
C#
public class MailAddressCollection : Collection<MailAddress>
Visual C++
public ref class MailAddressCollection : public Collection<MailAddress^>
F#
type MailAddressCollection =  
    class
        inherit Collection<MailAddress>
    end

El tipo MailAddressCollection expone los siguientes miembros.

  NombreDescripción
Método públicoMailAddressCollectionInicializa una instancia vacía de la clase MailAddressCollection.
Arriba
  NombreDescripción
Propiedad públicaCountObtiene el número de elementos contenido realmente en Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Propiedad públicaItemObtiene o establece el elemento que se encuentra en el índice especificado. (Se hereda de Collection<(Of <(T>)>)).
Propiedad protegidaItemsObtiene un contenedor de IList<(Of <(T>)>) para la colección Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Arriba
  NombreDescripción
Método públicoAdd(T)Agrega un objeto al final de la colección Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método públicoAdd(String)Agrega una lista de direcciones de correo electrónico a la colección.
Método públicoClearQuita todos los elementos de Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método protegidoClearItemsQuita todos los elementos de Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método públicoContainsDetermina si un elemento se encuentra en la colección Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método públicoCopyToCopia la totalidad de Collection<(Of <(T>)>) en una matriz Array unidimensional y compatible, comenzando en el índice especificado de la matriz de destino. (Se hereda de Collection<(Of <(T>)>)).
Método públicoEquals(Object)Determina si el objeto Object especificado es igual al objeto Object actual. (Se hereda de Object).
Método protegidoFinalizePermite que un objeto intente liberar recursos y realizar otras operaciones de limpieza antes de ser reclamado por la recolección de elementos no utilizados. (Se hereda de Object).
Método públicoGetEnumeratorDevuelve un enumerador que recorre en iteración la colección Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método públicoGetHashCodeActúa como función hash para un tipo concreto. (Se hereda de Object).
Método públicoGetTypeObtiene el objeto Type de la instancia actual. (Se hereda de Object).
Método públicoIndexOfBusca el objeto especificado y devuelve el índice de base cero de la primera aparición en toda la colección Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método públicoInsertInserta un elemento en el índice especificado de la colección Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método protegidoInsertItemInserta una dirección de correo electrónico en MailAddressCollection, en la ubicación especificada. (Invalida a Collection<(Of <(T>)>)..::.InsertItem(Int32, T)).
Método protegidoMemberwiseCloneCrea una copia superficial del objeto Object actual. (Se hereda de Object).
Método públicoRemoveQuita la primera aparición de un objeto específico de la interfaz Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método públicoRemoveAtQuita el elemento en el índice especificado de Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método protegidoRemoveItemQuita el elemento en el índice especificado de Collection<(Of <(T>)>). (Se hereda de Collection<(Of <(T>)>)).
Método protegidoSetItemReemplaza el elemento del índice especificado. (Invalida a Collection<(Of <(T>)>)..::.SetItem(Int32, T)).
Método públicoToStringDevuelve una representación de cadena de las direcciones de correo electrónico incluidas en este objeto MailAddressCollection. (Invalida a Object..::.ToString()()()).
Arriba
  NombreDescripción
Implementación explícita de interfacesMétodo privadoICollection..::.CopyToCopia los elementos de la interfaz ICollection a un objeto Array, a partir de un índice determinado de la clase Array. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesPropiedad privadaICollection<(Of <(T>)>)..::.IsReadOnlyObtiene un valor que indica si ICollection<(Of <(T>)>) es de solo lectura. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesPropiedad privadaICollection..::.IsSynchronizedObtiene un valor que indica si el acceso a ICollection está sincronizado (es seguro para la ejecución de subprocesos). (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesPropiedad privadaICollection..::.SyncRootObtiene un objeto que se puede utilizar para sincronizar el acceso a ICollection. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesMétodo privadoIEnumerable..::.GetEnumeratorDevuelve un enumerador que recorre en iteración una colección. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesMétodo privadoIList..::.AddAgrega un elemento a la interfaz IList. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesMétodo privadoIList..::.ContainsDetermina si la interfaz IList contiene un valor específico. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesMétodo privadoIList..::.IndexOfDetermina el índice de un elemento específico en la interfaz IList. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesMétodo privadoIList..::.InsertInserta un elemento en la interfaz IList, en el índice especificado. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesPropiedad privadaIList..::.IsFixedSizeObtiene un valor que indica si IList tiene un tamaño fijo. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesPropiedad privadaIList..::.IsReadOnlyObtiene un valor que indica si IList es de sólo lectura. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesPropiedad privadaIList..::.ItemObtiene o establece el elemento que se encuentra en el índice especificado. (Se hereda de Collection<(Of <(T>)>)).
Implementación explícita de interfacesMétodo privadoIList..::.RemoveQuita la primera aparición de un objeto específico de la interfaz IList. (Se hereda de Collection<(Of <(T>)>)).
Arriba

Las propiedades MailMessage..::.To, MailMessage..::.CC y MailMessage..::.Bcc devuelven instancias de esta clase que se utilizan para albergar las direcciones de correo electrónico respectivas.

Para obtener detalles sobre los formatos de la dirección de correo admitidos por la clase MailAddressCollection, vea la clase MailAddress.

El ejemplo siguiente agrega a MailAddressCollection una dirección de correo electrónico que devuelve la propiedad Bcc.

C#
        public static void CreateBccTestMessage(string server)
        {
            MailAddress from = new MailAddress("ben@contoso.com", "Ben Miller");
            MailAddress to = new MailAddress("jane@contoso.com", "Jane Clayton");
            MailMessage message = new MailMessage(from, to);
            message.Subject = "Using the SmtpClient class.";
            message.Body = @"Using this feature, you can send an e-mail message from an application very easily.";
            MailAddress bcc = new MailAddress("manager1@contoso.com");
            message.Bcc.Add(bcc);
            SmtpClient client = new SmtpClient(server);
            client.Credentials = CredentialCache.DefaultNetworkCredentials;
            Console.WriteLine("Sending an e-mail message to {0} and {1}.", 
                to.DisplayName, message.Bcc.ToString());
      try {
        client.Send(message);
      }  
      catch (Exception ex) {
        Console.WriteLine("Exception caught in CreateBccTestMessage(): {0}", 
                    ex.ToString() );
        }
      }
Visual C++
   static void CreateBccTestMessage( String^ server )
   {
      MailAddress^ from = gcnew MailAddress( L"ben@contoso.com",L"Ben Miller" );
      MailAddress^ to = gcnew MailAddress( L"jane@contoso.com",L"Jane Clayton" );
      MailMessage^ message = gcnew MailMessage( from,to );
      message->Subject = L"Using the SmtpClient class.";
      message->Body = L"Using this feature, you can send an e-mail message from an application very easily.";
      MailAddress^ bcc = gcnew MailAddress( L"manager1@contoso.com" );
      message->Bcc->Add( bcc );
      SmtpClient^ client = gcnew SmtpClient( server );
      client->Credentials = CredentialCache::DefaultNetworkCredentials;
      Console::WriteLine( L"Sending an e-mail message to {0} and {1}.", to->DisplayName, message->Bcc );
      try
      { 
          client->Send( message );
      }
      catch ( Exception^ ex )
      {
          Console::WriteLine(L"Exception caught in CreateBccTestMessage(): {0}", 
                        ex->ToString() );
      }
      client->~SmtpClient();
   }


.NET Framework

Compatible con: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Compatible con: 4, 3.5 SP1

Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Contenido de la comunidad   ¿Qué es Community Content?
Agregar contenido nuevo RSS  Anotaciones
Processing
© 2012 Microsoft. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker