Click or drag to resize
ZenophSMSaddRecipient Method (String, Boolean)
Adds a phone number to the destinations list. If the phone number already exists, it will be ignored.

Namespace: Zenoph.SMSLib
Assembly: Zenoph.SMSLib (in Zenoph.SMSLib.dll) Version: 2015.9.30.0 (2015.09.30.0)
Syntax
public bool addRecipient(
	string phonenum,
	bool igninv
)

Parameters

phonenum
Type: SystemString
The phone number to be added to the destinations list.
igninv
Type: SystemBoolean

An indicator that tells whether or not the method should ignore the throwing of Exception when phonenum is rejected for its invalidity or when it is not allowed on user routes. The default is false, and the method will throw Exception if phonenum is invalid or when it is not allowed on user routes.

Return Value

Type: Boolean
Returns true if the phone number was added to the destinations list otherwise it returns false.
Exceptions
ExceptionCondition
NullReferenceException Thrown if phonenum is null or empty and igninv is set to false.
Exception Thrown if the set message contains variables for personalised SMS irrespective of igninv. This exception is also thrown if phonenum is invalid or not allowed on user routes and igninv is set to false.
Remarks

The essence of igninv is particularly to prevent the termination of a loop that adds destinations. This can be achieved by setting igninv to true from calls in an iteration. In this case, the method will not terminate the iteration but will reject the unaccepted phone number and get the next.

If it is a requirement that all phone numbers be added before submission is done, igninv can be set to false. Then when a phone number is rejected, the iteration will be terminated and an Exception thrown to notify the rejection. Setting igninv to false is the same as making a call to the overloaded method addRecipient(String).

Examples
The following code adds phone numbers to the destinations list.
// Initialise the SMS object and perform authentication
ZenophSMS sms = new ZenophSMS();
sms.setUser("account_login");
sms.setPassword("account_password");
sms.authenticate();

// set the message below.
sms.setMessage("Hello there!");

/* add recipients below. */
// Exception will be thrown for the following if the phone number is invalid
// or  when not allowed on user routes since by default, igninv is set to false.
sms.addRecipient("0204444444");
sms.addRecipient("233204111111");

// The throwing of Exception will be ignored for the following if the phone number is
// invalid or when not allowed on user routes since igninv has been explicitly set to true.
sms.addRecipient("0204555555", true);
sms.addRecipient("233204222222", true);
See Also