ParseAddress Method  
 

Parse an Internet email address.

Syntax

object.ParseAddress( Address )

Parameters

Address
A string which specifies the email address to be parsed.

Return Value

A string containing the parsed address is returned if method was successful, otherwise an empty string is returned.

Remarks

The ParseAddress method parses a string which contains an email address and returns only the address portion, excluding any comments. An address may contain comments enclosed in parenthesis, or may specify a name along with the address in which case the address is enclosed in angle brackets. For example, consider the following header field value:

"User Name" <user@domain.com> (This is a comment)

The ParseAddress method would return "user@domain.com" if passed the above string, removing the name and any comments. Note that the ParseAddress method will only parse a single address. If multiple addresses are specified, they must be comma delimited and split prior to calling this method.

Example

The following example parses all of the recipient email addresses in the current message, storing them in the strAddresses string array.

Dim strAddresses() As String, strAddress As String
Dim nIndex As Integer, nAddresses As Integer
    
nAddresses = 0
strAddresses = Split(MailMessage1.To & "," & MailMessage1.Cc, ",")

For nIndex = 0 To UBound(strAddresses)
    If Len(Trim(strAddresses(nIndex))) > 0 Then
        strAddress = MailMessage1.ParseAddress(strAddresses(nIndex))
        If Len(strAddress) > 0 Then
            strAddresses(nAddresses) = strAddress
            nAddresses = nAddresses + 1
        End If
    End If
Next

See Also

Cc Property, From Property, To Property