简体   繁体   English

如何对移动应用进行编程以发送短信?

[英]How do I program a mobile app to send SMS?

I want a mobile app to send automated SMS. 我想要一个移动应用发送自动短信。 This will be in VB.Net. 这将在VB.Net中。 I've searched for articles on these but they are all about PC apps accessing a GSM modem or a mobile through a COM port. 我搜索了这些文章,但它们都是关于PC应用程序通过COM端口访问GSM调制解调器或移动设备的。 Is it the same process with mobile apps on the phone (not through a PC)? 手机上的移动应用程序(不是通过PC)是否与上述过程相同? If yes, and I am to treat the GSM modem as a "port", how would I connect to it? 如果是,并且我要将GSM调制解调器视为“端口”,该如何连接? If no, are there any useful resources for this? 如果否,是否有任何有用的资源?

Sending SMS is easy with windows mobile. 使用Windows Mobile轻松发送短信。 You need a reference to mobile.poutlook namespace. 您需要对mobile.poutlook命名空间的引用。

" Send SMS from Pocket PC, SMartphones, Windows mobile 从Pocket PC,SMartphones,Windows mobile发送短信

To send an SMS Message we'll first need to make reference to the Microsoft.WindowsMobile.PocketOutlook namespace. 要发送SMS消息,我们首先需要引用Microsoft.WindowsMo​​bile.PocketOutlook命名空间。

Imports Microsoft.WindowsMobile.PocketOutlook

After that it's as simple as creating a new instance of the SMSMessage class with an overloaded onstructor passing in the Recipient Mobile number and SMS text, then invoking the Send method " 之后,就像创建一个带有重载的讲师的SMSMessage类的新实例一样简单,它传入了收件人移动电话号码和SMS文本,然后调用Send方法

Source . 来源
Download VB code directly . 直接下载VB代码

MS reference . MS参考

MS Snippet: MS片段:

public void SmsMessageSend()
{
    SmsMessage smsMessage = new SmsMessage();

    //Set the message body and recipient.
    smsMessage.Body = "Would you like to meet for lunch?";
    smsMessage.To.Add(new Recipient("John Doe", "2065550199"));
    smsMessage.RequestDeliveryReport = true;

    //Send the SMS message.
    smsMessage.Send();

    return;
}

An automated VB translation of the above snippet: 以上代码段的自动VB翻译:

Public Sub SmsMessageSend()
    Dim smsMessage As New SmsMessage()

    'Set the message body and recipient.
    smsMessage.Body = "Would you like to meet for lunch?"

    smsMessage.To.Add(New Recipient("John Doe", "2065550199"))
    smsMessage.RequestDeliveryReport = True

    'Send the SMS message.
    smsMessage.Send()
    Return
End Sub

The above is not VB as asked, but unfortunately MS does not provide the VB snippet there. 以上不是要求的VB,但不幸的是,MS那里没有提供VB代码段。

All this will only work, if you are using a windows mobile device. 如果您使用的是Windows移动设备,则所有这些都将起作用。 It will not work on windows ce devices. 在Windows CE设备上将无法使用。

You should consider your internet searches for mobile API and code. 您应该考虑在互联网上搜索移动API和代码。 I always start with "compact framework" to get code related results only. 我总是从“紧凑框架”开始,仅获得与代码相关的结果。 Then I add the keywords I search for. 然后,添加搜索的关键字。 In example: "compact framework send sms" gives a good result list that you can work on. 例如:“紧凑型框架发送短信”给出了可以使用的良好结果列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM