ParseAddress Method

Parse an Internet e-mail address.

Syntax

object.ParseAddress( Address )

Remarks

The ParseAddress method parses a string which contains an e-mail 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.

Return Value

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

Example

The following example parses all of the recipient e-mail 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
            '
            ' The ParseAddress method will return an e-mail address
            ' or an empty string if the argument could not be parsed
            '
            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


Copyright © 2008 Catalyst Development Corporation. All rights reserved.