PowerTCP Mail for .NET
MailAddresses Class
Members  Example  See Also  Send comments on this topic.
Dart.PowerTCP.Mail Namespace : MailAddresses Class




A collection of MailAddress objects.

Object Model

MailAddresses ClassMailAddress Class

Syntax

Visual Basic (Declaration) 
<DefaultMemberAttribute("Item")>
Public Class MailAddresses 
   Inherits System.Collections.ArrayList
Visual Basic (Usage)Copy Code
Dim instance As MailAddresses
C# 
[DefaultMemberAttribute("Item")]
public class MailAddresses : System.Collections.ArrayList 
Managed Extensions for C++ 
[DefaultMemberAttribute("Item")]
public __gc class MailAddresses : public System.Collections.ArrayList 
C++/CLI 
[DefaultMemberAttribute("Item")]
public ref class MailAddresses : public System.Collections.ArrayList 

Example

The following example demonstrates the functionality of the MailAddresses collection.
Visual BasicCopy Code
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail"
' at the top of your class.

' Create a MailAddresses collection
Dim ma As New MailAddresses()

' Add a single email address
ma.Add(New MailAddress("address1@test.com"))

' Add a comma delimited list of email addresses.
ma.Add("address2@test.com,address3@test.com")

' Add an otherwise-delimited list of email addresses.
ma.Add("address2@test.com&address3@test.com", "&")

' Remove an email address
ma.Remove("address1@test.com")

' Remove any duplicate email addresses
ma.RemoveDuplicates()

System.Diagnostics.Debug.WriteLine(ma.ToString())

' Output
' ------------------
' <address2@test.com>,<address3@test.com>

' Add some more email addresses
ma.Add("mail1@other.com,mail2@other.com")

' Split the addresses by domain
Dim marray() As MailAddresses = ma.SplitByDomain()

Dim m As MailAddresses
For Each m In marray
   System.Diagnostics.Debug.WriteLine(m.ToString())
Next

' Output
' -----------------
' <mail1@other.com>,<mail2@other.com>
' <address2@test.com>,<address3@test.com>
'
C#Copy Code
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;"
// at the top of your class.

// Create a MailAddresses collection
MailAddresses ma = new MailAddresses();

// Add a single email address
ma.Add(new MailAddress("address1@test.com"));

// Add a comma delimited list of email addresses.
ma.Add("address2@test.com,address3@test.com");

// Add an otherwise-delimited list of email addresses.
ma.Add("address2@test.com&address3@test.com", "&");

// Remove an email address
ma.Remove("address1@test.com");

// Remove any duplicate email addresses
ma.RemoveDuplicates();

System.Diagnostics.Debug.WriteLine(ma.ToString());

// Output
// ------------------
// <address2@test.com>,<address3@test.com>

// Add some more email addresses
ma.Add("mail1@other.com,mail2@other.com");

// Split the addresses by domain
MailAddresses[] marray = ma.SplitByDomain();
foreach(MailAddresses m in marray)
   System.Diagnostics.Debug.WriteLine(m.ToString());

// Output
// -----------------
// <mail1@other.com>,<mail2@other.com>
// <address2@test.com>,<address3@test.com>
//

Remarks

The MailAddresses class represents a collection of MailAddress objects. To add a MailAddress to the MailAddresses collection either pass the strings representing the email addresses into the MailAddresses constructor, or use one of the MailAddresses.Add methods. Other advanced functionality of the MailAddresses object include MailAddresses.RemoveDuplicates, which automatically removes any duplicat addresses, MailAddresses.Verify, which verifies the validity of addresses, and MailAddresses.SplitByDomain, which returns multiple MailAddresses (contained in an ArrayList) containing addresses with the same domain.

Inheritance Hierarchy

System.Object
   System.Collections.ArrayList
      Dart.PowerTCP.Mail.MailAddresses

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.