Program example description:
A small program that calls the wp sms api, as shown in the figure below:
The procedure is as follows:
Using system; using system. collections. generic; using system. LINQ; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using Microsoft. phone. controls; using Microsoft. phone. tasks; namespace phoneapp_smssample {public partial class mainpage: Phoneapplicationpage {export mychooser = NULL; smscomposetask SMS = NULL; string phonenumber = ""; // constructor public mainpage () {initializecomponent (); mychooser = new phonenumberchoosertask (); mychooser. completed + = new eventhandler <phonenumberresult> (mychooser_completed);} void mychooser_completed (Object sender, phonenumberresult e) {// select the operation if (E. taskresult = taskresult. OK) {This. somebodyformphonebook. TEXT = E. displayname + ";"; phonenumber = E. phonenumber ;}} private void tosomebody_click (Object sender, routedeventargs e) {// The recipient calls the phone book mychooser. show ();} private void button1_click (Object sender, routedeventargs e) {// send // the sender and the content to be sent cannot be empty if (somebodyformphonebook. TEXT = "" | smscontent. TEXT = "") {MessageBox. show ("the sender and content cannot be blank! "); Return;} SMS = new smscomposetask (); SMS. To = phonenumber; SMS. Body = smscontent. Text; SMS. Show ();}}}