| Visual Basic (Declaration) | |
|---|---|
Public Overloads Sub Add( _ ByVal SourceString As String, _ ByVal Delimiter As String _ ) | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As MailAddresses Dim SourceString As String Dim Delimiter As String instance.Add(SourceString, Delimiter) | |
| C# | |
|---|---|
public void Add( string SourceString, string Delimiter ) | |
| Managed Extensions for C++ | |
|---|---|
public: void Add( string* SourceString, string* Delimiter ) | |
| C++/CLI | |
|---|---|
public: void Add( String^ SourceString, String^ Delimiter ) | |
Parameters
- SourceString
- An RFC822 formatted string of delimited email MailAddresses.
- Delimiter
- Any string delimiter used to split the message.
Return Value
An ArrayList of strings that were not accepted.The following example demonstrates the functionality of the MailAddresses collection.
| Visual Basic | Copy 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> // | |
This constuctor initializes the MailAddresses object with a series of delimited email address formatted strings. For example:
sourcestring = "address1@server.com&address2@server.com" delimiter = "&"
The parameters above would result in a MailAddresses collection containing two MailAddress objects (for "address1@server.com" and "address2@server.com"). If the string includes email addresses that were not accepted, they would be returned in an ArrayList by the method.
The MailAddresses passed must contain all comments in between quotes. The area outside the quotes is delimited by the given Delimiter, and everything outside the quotes is the MailAddress.
Target Platforms: Microsoft .NET Framework 2.0