<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="../notes.xsl"?>
<Documentation>
	<Title code="0410">SendMessage</Title>
	<Overview>
		<p>Schema to send SMS and email messages from a user's account.</p>
	</Overview>
	<Request schema="0410_RequestSendMessage.xsd">
		<p>The 'UserID' and 'Password' elements identify the account.
			The 'ServiceName' element must be set to 'SendMessage'.
			The 'SoftwareVersion' element is for internal 2SMS use only and should not be set.</p>
		<h3>1 Message Types</h3>
		<p>The 'ServiceDetail' element should contain child elements of one of the following types:</p>
		<h4>1.1 SingleMessage elements</h4>
		<p>Each element is used to send a single message to a single SMS destination.
			By using multiple elements it is possible to customize a message text for different destinations.
			Up to 500 'SingleMessage' elements may be supplied.
			Each element should contain the following children:</p>
		<ul>
			<li>A 'Destination' element that contains the SMS number to receive the message (email destinations are not allowed).</li>
			<li>A 'Text' element that holds the message to be sent
					(messages over 160 characters are sent in a number of parts).</li>
			<li>A set of optional elements as described in Section 2 below.</li>
		</ul>
		<p>The advantage of this method is the flexibility to set different text, destination and send options in multiple elements
				(e.g. to provide different message text including recipient names).
				The disadvantage is that only one destination is allowed per 'SingleMessage' element.</p>
		<h4>1.2 BulkMessage elements</h4>
		<p>This method is used to send the same SMS message to multiple recipients.
			Only a single 'BulkMessage' element may be supplied.
			The element should contain the following children:</p>
		<ul>
			<li>A 'DestinationList' element with up to 1000 'Destination' children
					which contain the SMS numbers to receive the message (email destinations are not allowed).</li>
			<li>A 'Text' element that holds the message to be sent
					(messages over 160 characters are sent in a number of parts).</li>
			<li>A set of optional elements as described in Section 2 below.</li>
		</ul>
		<h4>1.3 GroupMessage elements</h4>
		<p>This method is used to send the same SMS message to one or more groups of contacts defined on the account.
			Only a single 'GroupMessage' element may be supplied.
			The element should contain the following children:</p>
		<ul>
			<li>A 'GroupList' element with up to 100 'GroupID' children which detail the groups to receive the message
				(see schema code <a href="./0140_documentation.xml">0140</a> for info on obtaining GroupID values).
				Note that messages will be sent only to SMS destinations in the groups as this method does not support email.
				If a destination occurs multiple times within different groups only a single message will be sent to that destination.</li>
			<li>A 'Text' element that holds the message to be sent
					(messages over 160 characters are sent in a number of parts).</li>
			<li>A set of optional elements as described in Section 2 below.</li>
		</ul>
		<h4>1.4 CombiMessage elements</h4>
		<p>This method is used to send a message to both individual and group destinations,
			and is the only method that provides support for email.
			Either one or two 'CombiMessage' elements may be sent.
			Each element should contain the following children:</p>
		<ul>
			<li>A 'CombiList' element which may hold up to 1000 'Individual' children, the text content of which identify 
					single email or SMS destinations as specified by the 'type' attribute.</li>
			<li>The same 'CombiList' element may also hold up to 100 'GroupID' children, the text content of which identify
					groups of individuals to receive the message
					(see schema code <a href="./0140_documentation.xml">0140</a> for info on obtaining GroupID values).
					The type attribute determines whether only email, only SMS or both email and SMS destinations receive the message.
					If a destination occurs in multiple groups (and possibly 'Individual' elements) only a single message will be sent to that destination.</li>
			<li>A 'Text' element that holds the message to be sent
					(messages over 160 characters are sent in a number of parts).</li>
			<li>An optional 'EmailDetails' element may be supplied when emails are being sent (see Section 3 below).</li>
			<li>A set of optional elements as described in Section 2 below.</li>
		</ul>
		<h3>2. Optional Elements and their Defaults</h3>
		<p>Any combination of the following optional elements may be supplied:</p>
		<ul>
			<li>A 'GUID' element to assign a reference to the message batch for identification purposes.
				If not set a default value is assigned based on when the request was received.</li>
			<li>A 'DateToSend' element containing a future time at which the messages will be sent. The format must be MM/dd/yyyy hh:mm:ss.
				If not set the messages will be sent immediately.</li>
			<li>A 'Header' element to specify which header to employ when additional SMS headers have been purchased
				(see <a href="http://www.2sms.com/solutions.aspx?Section=headers">here</a> for more details on headers).
				If not set the default header for the account is used.</li>
			<li>A 'Repeat' element may be used to schedule repeating messages.
				The first message will go out at a time determined by the 'DateToSend' element (default is immediately).
				The message is then sent again at time intervals of 'Frequency' minutes for a further 'Repetitions' times
				(thus the message will be sent a total of (repetitions + 1) times including the initial send).</li>
			<li>The 'SoftwareVersion' element is present to support legacy code and should not be used.</li>
		</ul>
		<h3>3. Setting Email options</h3>
		<p>Sending of emails and hence email options are only available for CombiMessage requests. An 'EmailDetails'
			child of 'ServiceDetail' may be supplied containing any of the following optional children:</p>
		<ul>
			<li>A 'Subject' element containing the email subject. The default is an empty subject string.</li>
			<li>A 'FromName' element containing the email sender's name. The default is the first and last names registered for the account.</li>
			<li>A 'FromAddress' element containing the email address to supply as the sender. The default is 'support@2sms.com'.</li>
			<li>A 'ReplyTo' element containing the email address to which email replies will be directed.
					The default is the current username of the account or 'support@2sms.com' if this is not recognised as an email address.</li>
			<li>A 'MessageType' element to identify if the email should be sent in the default 'Email' (plain text) or alternative 'HTML' format.</li>
		</ul>
	</Request>
	<Response schema="0410_ResponseSendMessage.xsd">
		<p>This method returns a successful "00/OK" response if all messages were successfully scheduled for sending.
			The 'Result' element confirms how many messages were sent and the remaining account balance.
			The following additional information is also returned:</p>
		<h3>1 The 'Detail' element</h3>
		<p>The 'Detail' element contains the following child elements:</p>
		<ul>
			<li>A 'MessagesSent' element containing the total number of messages sent.
				Note that separate components of long SMS messages (i.e. those over 160 characters) count as separate messages.</li>
			<li>A 'CreditsRemaining' element containing the number of AnyTime credits remaining on the account.</li>
			<li>An 'OffPeakCreditsRemaining' element containing the number of OffPeak credits remaining on the account.</li>
			<li>
        The 'Messages' element is provided for legacy support when the request composed 'SingleMessage' elements.
        It returns a 2SMS message 'ID' value along with the message's 'Destination'.
        Please note: If you are sending a combi-message and you want the MessageIDs returned you must provide the 
        ReturnMessageIDs element as true inside the CombiMessage element
      </li>
		</ul>
		<h3>2 The 'OutputData' element</h3>
		<p>The 'OutputData' element contains the following child nodes:</p>
		<ul>
			<li>A 'Batches' element with one child for each batch sent out by the request.
				The number of 'Batch' children equals the number of message elements supplied.
				An additional 'BatchOptOut' element will be present if opt-out messages were required
				(e.g. when sending the initial message to US numbers).
				The batch is identified by the values in the 'GUID' and 'DateID' attributes.
				See schema code <a href="./0350_documentation.xml">0350</a> for more info on dealing with message batches.</li>
			<li>An 'individualSMS' attribute containing the number of SMS messages sent to destinations specified explicitly.</li>
			<li>A 'groupSMS' attribute containing the number of SMS messages sent to destinations extracted from a group.</li>
			<li>An 'individualEmails' attribute containing the number of email messages sent to destinations specified explicitly</li>
			<li>A 'groupEmails' attribute containing the number of email messages sent to destinations extracted from a group.</li>
			<li>A 'peakCredits' attribute containing the number of AnyTime credits charged for the request.</li>
			<li>An 'offPeakCredits' attribute containing the number of OffPeak credits charged for the request.</li>
		</ul>
	</Response>
</Documentation>