vb.net 如何在VB.Net中实现短信发送?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18035583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:32:06  来源:igfitidea点击:

how to implement SMS sending in VB.Net?

vb.netvisual-studio-2010sms

提问by Vikram

I need to have some idea (some code) to implement sms sending on mobile phones using windows application developed in visual basic 2010.
I have done with email sending, but i have no idea about sms sending.

我需要有一些想法(一些代码)来使用 Visual Basic 2010 中开发的 Windows 应用程序在手机上实现短信发送。
我已经完成了电子邮件发送,但我不知道短信发送。

I have done sms sending using free API's in PHP. But in vb.net I want to do it without APIs..(I want to connect my mobille to my application)

我已经使用 PHP 中的免费 API 发送了短信。但是在 vb.net 中,我想在没有 API 的情况下做到这一点.. (我想将我的手机连接到我的应用程序)

So any knowledgeable comment will be big help for me...Thanks.

所以任何知识渊博的评论对我来说都会有很大的帮助......谢谢。

回答by Ben P. Dorsi-Todaro

Not sure if I fully understand what your saying. But I think you simply want to send an SMS message in your VB .Net application. For example I think what your asking is how to send an SMS message from your VB .Net application to another phone number. If that is the case you should do the same as you would when sending E-Mails with VB .Net and utilize the SMS gateways. https://en.wikipedia.org/wiki/List_of_SMS_gateways

不确定我是否完全理解你的意思。但我认为您只是想在您的 VB .Net 应用程序中发送 SMS 消息。例如,我认为您要问的是如何将 SMS 消息从您的 VB .Net 应用程序发送到另一个电话号码。如果是这种情况,您应该像使用 VB .Net 发送电子邮件一样使用 SMS 网关。https://en.wikipedia.org/wiki/List_of_SMS_gateways

Remember only one phone number can exist so sending an sms message to [email protected] and [email protected] will only will work. Only one message will be recieved because the other SMS gateways don't have a number for it. So try creating a list of all the SMS gateways and having the the user type their number in and then sending the message out with the users entered [email protected] will work.

请记住,只能存在一个电话号码,因此向 [email protected][email protected] 发送短信只会有效。只会收到一条消息,因为其他 SMS 网关没有它的号码。因此,尝试创建所有 SMS 网关的列表,让用户输入他们的号码,然后将消息发送出去,用户输入 [email protected] 即可。

    'Now lets test the E-Mail functionality on our phone gap site. This section does just that.
    Dim email As New MailMessage
    Dim mailfrom As String
    Dim mailto As String

    mailfrom = lblAddress.Text
    mailto = tbNumber.Text

    email.To.Add(mailto)
    email.From = New MailAddress(mailfrom)
    email.Body = tbmsgBody.Text

    Dim sendserver As String

    sendserver = lblSMTP.Text
    Dim SMTP As New SmtpClient(sendserver)
    Dim username As String
    Dim password As String

    username = lblUName.Text
    password = lblPW.Text

    If lblSSL.Text = "Yes" Then
        SMTP.EnableSsl = True
    Else : SMTP.EnableSsl = False
    End If

    SMTP.Credentials = New System.Net.NetworkCredential(username, password)
    Dim portnum As String

    portnum = lblPort.Text
    SMTP.Port = portnum
    SMTP.Send(email)
    MessageBox.Show("Message Sent")
ElseIf cbAction.Visible = True And cbAction.Text = "Send" And tbSubject.Visible = False Then
    'The idea behind this section is mainly to use the SMS Gateways and using the same E-Mail Form. Since their will only always be just one phone. We can try to send the same message to all of of the SMS gateways for that number. Obviously only one message will ever be recieved and the sender of the message will get a whole bunch of delivery failure messages. But at least one will get to the actual phone number.
    Dim email As New MailMessage
    Dim mailfrom As String
    Dim mailto As String

    mailfrom = lblAddress.Text
    mailto = tbNumber.Text
    'Now lets add our SMS Gateways
    'Since this is a SMS and MMS portion their will be no need to add a subject feild.
    email.Bcc.Add(mailto + "@myboostmobile.com")
    email.Bcc.Add(mailto + "@vtext.com")
    email.Bcc.Add(mailto + "@sms.airfiremobile.com")
    email.Bcc.Add(mailto + "@msg.acsalaska.com")
    email.Bcc.Add(mailto + "@sms.alltelwireless.com")
    email.Bcc.Add(mailto + "@mms.alltelwireless.com")
    email.Bcc.Add(mailto + "@message.Alltel.com")
    email.Bcc.Add(mailto + "@text.wireless.alltel.com")
    email.Bcc.Add(mailto + "@mms.alltel.net")
    email.Bcc.Add(mailto + "@paging.acswireless.com")
    email.Bcc.Add(mailto + "@txt.att.net")
    email.Bcc.Add(mailto + "@mmode.com")
    email.Bcc.Add(mailto + "@mms.att.net")
    email.Bcc.Add(mailto + "@txt.att.net")
    email.Bcc.Add(mailto + "@cingularme.com")
    email.Bcc.Add(mailto + "@mobile.mycingular.com")
    email.Bcc.Add(mailto + "@page.att.net")
    email.Bcc.Add(mailto + "@sms.smartmessagingsuite.com")
    email.Bcc.Add(mailto + "@bellsouth.cl")
    email.Bcc.Add(mailto + "@sms.bluecell.com")
    email.Bcc.Add(mailto + "@mms.myblueworks.com")
    email.Bcc.Add(mailto + "@cellcom.quiktxt.com")
    email.Bcc.Add(mailto + "@csouth1.com")
    email.Bcc.Add(mailto + "@cwemail.com")
    email.Bcc.Add(mailto + "@sms.cvalley.net")
    email.Bcc.Add(mailto + "@cingular.com")
    email.Bcc.Add(mailto + "@cingular.com")
    email.Bcc.Add(mailto + "@mobile.mycingular.com")
    email.Bcc.Add(mailto + "@cingulartext.com")
    email.Bcc.Add(mailto + "@sms.cleartalk.us")
    email.Bcc.Add(mailto + "@sms.mycricket.com")
    email.Bcc.Add(mailto + "@mms.mycricket.com")
    email.Bcc.Add(mailto + "@cspire1.com")
    email.Bcc.Add(mailto + "@sms.edgewireless.com")
    email.Bcc.Add(mailto + "@SMS.elementmobile.net")
    email.Bcc.Add(mailto + "@mobile.gci.net")
    email.Bcc.Add(mailto + "@gscsms.com")
    email.Bcc.Add(mailto + "@hawaii.sprintpcs.com")
    email.Bcc.Add(mailto + "@myhelio.com")
    email.Bcc.Add(mailto + "@iwirelesshometext.com")
    email.Bcc.Add(mailto + "@mobile.kajeet.net")
    email.Bcc.Add(mailto + "@text.longlines.com")
    email.Bcc.Add(mailto + "@mymetropcs.com")
    email.Bcc.Add(mailto + "@messaging.sprintpcs.com")
    email.Bcc.Add(mailto + "@pm.sprint.com")
    email.Bcc.Add(mailto + "@messaging.nextel.com")
    email.Bcc.Add(mailto + "@page.nextel.com")
    email.Bcc.Add(mailto + "@tmomail.net")
    email.From = New MailAddress(mailfrom)
    email.Subject = tbSubject.Text
    email.Body = tbmsgBody.Text

    Dim sendserver As String

    sendserver = lblSMTP.Text
    Dim SMTP As New SmtpClient(sendserver)
    Dim username As String
    Dim password As String

    username = lblUName.Text
    password = lblPW.Text

    If lblSSL.Text = "Yes" Then
        SMTP.EnableSsl = True
    Else : SMTP.EnableSsl = False
    End If

    SMTP.Credentials = New System.Net.NetworkCredential(username, password)
    Dim portnum As String

    portnum = lblPort.Text
    SMTP.Port = portnum
    SMTP.Send(email)
    MessageBox.Show("Message Sent")

You can view entire source code on https://github.com/LinuxPhreak/PhoneGap-Emulators

您可以在https://github.com/LinuxPhreak/PhoneGap-Emulators上查看完整的源代码