Parse an Internet email address.
Syntax
object.ParseAddress( Address )
Parameters
- Address
- A string value that specifies the address to be parsed.
Return Value
A string that contains the email address or an empty string if the
address could not be parsed.
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 string
"user@domain.com" would be returned 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(InternetMail1.To & "," & _
InternetMail1.Cc & "," & _
InternetMail1.Bcc, ",")
For nIndex = 0 To UBound(strAddresses)
If Len(Trim(strAddresses(nIndex))) > 0 Then
strAddress = InternetMail1.ParseAddress(strAddresses(nIndex))
If Len(strAddress) > 0 Then
strAddresses(nAddresses) = strAddress
nAddresses = nAddresses + 1
End If
End If
Next
See Also
Recipient Property,
Recipients Property,
ParseMessage Method
|