2. enter the corresponding information according to the options shown in Figure 02, and click "log on to mobile Dream". If the registration is successful, alibaba Cloud mobile will send an 8-bit password to your registered mobile phone to get the interface shown in Figure 03.
Link: http://dev.yesky.com/imagelist/06/03/dvnl2q1z8y2h.jpg
Figure 03: page 3 of Sina registration mobile phone
This password must be retained. The password must be used to send the text message below.
Iii. Environment for program design, debugging, and running in this article:
(1). Microsoft Windows 2000 Server Edition.
(2). Visual Studio. NET 2003 enterprise build version,. NET Framework SDK version 4322.
Iv. Visual C # specific steps for sending short messages:
Visual C # The Key to sending short messages is to reference the Web service provided by Sina. Call the sendxml method of this service. The following describes how to use Visual C # To reference web service to send short messages:
1. Start Visual Studio. NET.
2. Select File, new, and project. The new project dialog box is displayed.
3. Set project type to Visual Basic Project ].
4. Set template to Windows application ].
5. Enter text message in the name text box ].
6. in the location text box, enter E:/.. Net project, and then click OK. the. Net project "directory generates a folder named" SMS "and creates a project file named" SMS.
7. set Visual Studio. switch the current window of net to the form1.cs window, drag the following components to form1 form from the Windows Forms components tab in the toolbox, and perform the corresponding operations:
Four label components.
Four textbox components.
A button component sends short messages. After the button component is dragged into the form1 design form, double-click it, the system will generate the processing code corresponding to the Click Event of the component in the form1.cs file.
8. Switch the current window of Visual Studio. net to the code editing window of form1.vb and replace the code corresponding to the initializecomponent process in form1.cs with the following code. The following code serves to initialize the components added to the form:
Private void initializecomponent ()
{
This. textbox1 = new system. Windows. Forms. Textbox ();
This. textbox2 = new system. Windows. Forms. Textbox ();
This. textbox3 = new system. Windows. Forms. Textbox ();
This. button1 = new system. Windows. Forms. Button ();
This. label1 = new system. Windows. Forms. Label ();
This. label2 = new system. Windows. Forms. Label ();
This. label3 = new system. Windows. Forms. Label ();
This. label4 = new system. Windows. Forms. Label ();
This. textbox4 = new system. Windows. Forms. Textbox ();
This. suspendlayout ();
This. textbox1.location = new system. Drawing. Point (144, 16 );
This. textbox1.name = "textbox1 ";
This. textbox1.size = new system. Drawing. Size (184, 21 );
This. textbox1.tabindex = 0;
This. textbox1.text = "";
This. textbox2.location = new system. Drawing. Point (144, 69 );
This. textbox2.name = "textbox2 ";
This. textbox2.passwordchar = ''''''''*'''''''';
This. textbox2.size = new system. Drawing. Size (184, 21 );
This. textbox2.tabindex = 1;
This. textbox2.text = "";
This. textbox3.location = new system. Drawing. Point (144,122 );
This. textbox3.name = "textbox3 ";
This. textbox3.size = new system. Drawing. Size (184, 21 );
This. textbox3.tabindex = 2;
This. textbox3.text = "";
This. button1.location = new system. Drawing. Point (152,256 );
This. button1.name = "button1 ";
This. button1.size = new system. Drawing. Size (80, 32 );
This. button1.tabindex = 4;
This. button1.text = "send ";
This. button1.click + = new system. eventhandler (this. button#click );
This. label1.location = new system. Drawing. Point (56, 24 );
This. label1.name = "label1 ";
This. label1.size = new system. Drawing. Size (88, 16 );
This. label1.tabindex = 5;
This. label1.text = "registered mobile phone number :";
This. label2.location = new system. Drawing. Point (88, 77 );
This. label2.name = "label2 ";
This. label2.size = new system. Drawing. Size (72, 16 );
This. label2.tabindex = 6;
This. label2.text = "Password :";
This. label3.location = new system. Drawing. Point (56,128 );
This. label3.name = "label3 ";
This. label3.size = new system. Drawing. Size (96, 16 );
This. label3.tabindex = 7;
This. label3.text = "target mobile phone number :";
This. label4.location = new system. Drawing. Point (96,176 );
This. label4.name = "label4 ";
This. label4.size = new system. Drawing. Size (72, 16 );
This. label4.tabindex = 8;
This. label4.text = "content :";
This. textbox4.location = new system. Drawing. Point (144,175 );
This. textbox4.multiline = true;
This. textbox4.name = "textbox4 ";
This. textbox4.size = new system. Drawing. Size (184, 48 );
This. textbox4.tabindex = 3;
This. textbox4.text = "";
This. autoscalebasesize = new system. Drawing. Size (6, 14 );
This. clientsize = new system. Drawing. Size (410,303 );
This. Controls. Add (this. button1 );
This. Controls. Add (this. textbox4 );
This. Controls. Add (this. textbox3 );
This. Controls. Add (this. textbox2 );
This. Controls. Add (this. textbox1 );
This. Controls. Add (this. label4 );
This. Controls. Add (this. label3 );
This. Controls. Add (this. label2 );
This. Controls. Add (this. label1 );
This. formborderstyle = system. Windows. Forms. formborderstyle. fixedsingle;
This. maximizebox = false;
This. Name = "form1 ";
This. Text = "Visual C # SMS sending ";
This. resumelayout (false );
}
Now, the interface design and functional implementation preparations for the [SMS] project are complete, as shown in Figure 04:
Link: http://dev.yesky.com/imagelist/06/03/wz785b4af6d0.jpg
Figure 04: design page of the [SMS] project
9. Select Solution Explorer for SMS and right-click reference. The add web reference dialog box is displayed. In this dialog box, enter "http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl" in the URL text box and click the go to button to get the page shown in Figure 05:
Http://dev.yesky.com/imagelist/06/03/qa7cz8sq56n7.jpg
Figure 05: Web reference page added in the text message Project
Click Add reference in Figure 04 to add the Web service provided by Sina.
10. set visual stuido. switch the current window of net to the code editing window of form1.cs, and replace the code corresponding to the click event of button1 in from1.cs with the following code, the following code calls the sendxml method provided in the introduced Web service to send short messages to a specified mobile phone:
Private void button#click (Object sender, system. eventargs E)
{
SMS .cn.com. Sina. smsinter. smsws = new SMS .cn.com. Sina. smsinter. smsws ();
String result = ws. sendxml ("Sina", textbox1.text, textbox2.text, textbox3.text, textbox4.text, "new ");
MessageBox. Show (result );
}
11. Now, after the above steps are correctly executed, all the work of the text message project has been completed. Click F5 to run the program. after entering the register mobile phone number, password, target mobile phone number, and content, click send, the program sends a short message to the specified mobile phone number.
V. Summary:
This Visual C # Short Message sending method is introduced in this article. The key to solving this problem is to reference the web service and call the method in this web service. In the full text, is this method very simple. Finally, we would like to remind you that the use of such short messages is not a free lunch. For the billing standard, refer to the relevant instructions on the Sina Wireless Network Station. Each message is charged for a dime, fees are charged from the phone number registered on Sina. When using the method described in this article to send short messages, there is usually a delay after sending is completed. This is because the backend uses the message queue mechanism, but this delay generally takes only a few seconds.
Transfer http://www.chinacs.net/archives/5/2006/3591.html