ValidateAddress method: MCFMailUtil class
Syntax
ValidateAddress(addresslist)
In which addresslist is a list of email addresses in the form:
email_address1 [{,|;} email_address2] ...
Description
Use the ValidateAddress method to validate a comma- or semicolon-separated list of email addresses. This method checks the syntax of the email address. It does not verify the domain name or the validity of the user name.
This method returns true if successful. If the return value is false, the following MCFMailUtil properties are set accordingly:
-
badaddresses
-
ErrorDescription
-
ErrorDetails
-
ErrorMsgParamsCount
-
MessageNumber
-
MessageSetNumber
In addition you can use the GetErrorMsgParam method to return each of the substitution strings used to format the error message.
Parameters
| Parameter | Description |
|---|---|
|
addresslist |
Specify the email address (or addresses) you want to verify as a comma- or semicolon-separated list. |
Returns
A Boolean value: true if the specified email addresses are valid, false otherwise. When ValidateAddress returns false, the badaddresses property will contain an array of all invalid addresses.
Example
import PT_MCF_MAIL:*;
Local PT_MCF_MAIL:MCFMailUtil &emailutil = create PT_MCF_MAIL:MCFMailUtil();
Local boolean &result = &emailutil.ValidateAddress(&email.Recipients);
Local array of string &bAddresses = &emailutil.badaddresses;
If (&result = False) Then
If (&bAddresses <> Null) Then
&i = 0;
While &bAddresses.Next(&i)
Warning ("Bad email address in input = " | &bAddresses [&i]);
End-While;
End-If;
End-If;