. Net sends short messages to mobile phones

Source: Internet
Author: User

I recently used the SMS sending function in the development project. I checked the SMS interface. Because it was web development, I chose the com api in the interface!

 

Of course, you must first reference the empp. dll file in the interface and register

Then implement the following code:

/// <Summary>
/// SMS sending class
/// </Summary>
Public class SMS: DB
{
/// <Summary>
/// Send a text message
/// </Summary>
/// <Param name = "nRecordCount"> mobile phone number. Separate multiple mobile phone numbers with | and end with | </param>
/// <Param name = "nOrder"> text message content </param>
Public static void SendSMS (string mobiles, string contents)
{
// SMS Server IP Address
String host = "211.136.163.68 ";
// SMS Server Port
Int port = 9981;

// Sending account
String accountId = "";
String serviceId = "0 ";
// Send the account password
String password = "";
EMPPLib. emptcl empp = new EMPPLib. emptclClass ();

EMPPLib. ConnectResultEnum result = ConnectResultEnum. CONNECT_OTHER_ERROR;
Result = empp. connect (host, port, accountId, password );

String msg = contents;
EMPPLib. receivmessage shortMsg = new EMPPLib. receivmessageclass ();
ShortMsg. srcID = accountId;
ShortMsg. ServiceID = serviceId;
ShortMsg. needStatus = true;
EMPPLib. Mobiles mobs = new EMPPLib. MobilesClass ();
If (mobiles. indexof ("|")>-1)
{
Char [] Cut = new char [] {'| '};
For (int32 I = 0; I <mobiles. Split (CUT). Length-1; I ++ ){
Mobs. Add (mobiles. Split (CUT) [I]. tostring ());
}
}
Else
{
Mobs. Add (mobiles );
}
Shortmsg. destmobiles = mobs;
Shortmsg. content = MSG;
Shortmsg. sendnow = true;

Empp. needstatus = true;
If (empp! = NULL & empp. Connected = true)
{
Empp. Submit (shortmsg );
}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.