C#
// Create XML message
MemoryStream ms = new MemoryStream();
XmlTextWriter xmlw = new XmlTextWriter(ms, System.Text.Encoding.UTF8);
xmlw.WriteStartDocument();
xmlw.WriteStartElement("Delivery");
xmlw.WriteElementString("PackageID", lblPackageID.Text);
xmlw.WriteElementString("Delivered", txtDelivered.Text);
xmlw.WriteEndElement();
xmlw.WriteEndDocument();
xmlw.Flush();
ms.Seek(0, SeekOrigin.Begin);
StreamReader sr = new StreamReader(ms);
txtMessage.Text = sr.ReadLine();
lblMessage.Text = "Message (" + txtMessage.Text.Length.ToString() + "
chars):";
this.Refresh();
xmlw.Close();
sr.Close();
// Send message
if (0 == SMSHelper.SendSMS("+15555550123", txtMessage.Text))
MessageBox.Show("Message sent!", this.Text, MessageBoxButtons.OK,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
else
MessageBox.Show("Could not send message!", this.Text);
VB.Net
'Create XML message
Dim ms As New MemoryStream()
Dim xmlw As New XmlTextWriter(ms, System.Text.Encoding.UTF8)
With xmlw
.WriteStartDocument()
.WriteStartElement("Delivery")
.WriteElementString("PackageID", lblPackageID.Text)
.WriteElementString("Delivered", txtDelivered.Text)
.WriteEndElement()
.WriteEndDocument()
.Flush()
End With
ms.Seek(0, SeekOrigin.Begin)
Dim sr as New StreamReader(ms)
txtMessage.Text = sr.ReadLine()
lblMessage.Text = "Message (" & txtMessage.Text.Length.ToString() & "chars):"
Me.Refresh()
xmlw.Close()
sr.Close()
'Send message
If 0 = SMSHelper.SendSMS("+15555550123", txtMessage.Text)
MessageBox.Show("Message sent!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
Else
MessageBox.Show("Could not send message!", Me.Text)
End If