Is it possible to send sms from an asp.net webform? :eek:

I have searched multiple sites, but can't really find anything useful..any advices?

Dani AI

Generated

Short answer: yes — an ASP.NET WebForm (VB.NET codebehind) can send SMS. Three practical routes work in real projects: (1) a third‑party SMS gateway with an HTTP/REST or SDK interface (recommended for reliability, delivery receipts, international reach), (2) a locally attached GSM modem and AT commands (full control; hardware and SIM required), or (3) carrier email‑to‑SMS gateways (quick for tests but fragile and being phased out). This lines up with the prior replies from , and . (twilio.com)

A minimal, production‑orientated approach is to call a gateway REST API from the ASP.NET codebehind. Example (conceptual VB.NET using HttpClient — protect credentials and prefer provider SDKs when available):

Imports System.Net.Http
Imports System.Text

Protected Async Function SendSmsAsync() As Task
    Using client As New HttpClient()
        client.DefaultRequestHeaders.Authorization =
            New System.Net.Http.Headers.AuthenticationHeaderValue("Basic",
                Convert.ToBase64String(Encoding.ASCII.GetBytes("ACCOUNT_SID:AUTH_TOKEN")))
        Dim payload = New Dictionary(Of String, String) From {
            {"To", "+15551234567"},
            {"From", "+15557654321"},
            {"Body", "Alert: test"}
        }
        Dim content = New FormUrlEncodedContent(payload)
        Dim resp = Await client.PostAsync("https://api.YOUR-GATEWAY/messages", content)
        Dim text = Await resp.Content.ReadAsStringAsync()
    End Using
End Function

Use E.164 phone formatting, TLS, secure config storage for secrets, and provider callbacks for status. Provider SDKs (e.g., Twilio .NET) simplify retries, formatting and delivery tracking. (twilio.com)

If hardware is preferred, control a GSM modem over serial and use AT commands (AT+CMGF=1 then AT+CMGS to send). That gives two‑way SMS capability but adds device management and concurrency concerns; test the modem interactively before automating. This is the route to explore for on‑premise solutions. (digikey.ch)

Cautions and quick tips: do not rely long‑term on public email‑to‑SMS gateways (many providers/carriers are shutting them down); if legacy systems require email triggers, bridge them to an internal SMTP listener that calls an SMS API. Avoid using SmtpClient for new systems (consider MailKit) and always add CAPTCHA/rate limits, logging, and consent/opt‑in checks to prevent abuse and meet regulations (as suggested). (twilio.com)

Recommended Answers

All 6 Replies

I believe there are classes built into the .NET Compact Framework for Short Message Service.

sms is complex and not free but can be done. There are gateways which you can setup with your provider. There is a way to do it via email and is usually d i know them for usa but not for uk. I would think vodafone would be but dont quote me on it.

Hello everyone. I am new to VB.NET and ive been assinged an SMS send/receive (PC to mobile) applcation...I would be very grateful if anyone can help/tutor/send sample code for help.
Thanks guyz, ROD (developer at MEA)
<snipped>

Sending SMS through your web or winforms application is not very complicated. you can do this through one of the following routes:-

1. Through a gateway : You'll need to subscribe to a gateway services which would allow you to send sms either through a web service or simple HTTP posts. The gateway however will charge you per sms and most of the gateways offer worldwide coverage with guaranteed delivery. i'd go along with this mechanism as it is simpler and easier to implement. I have integrated sms gateways in a couple of recent projects and it works perfectly fine.

2. Connect a GSM modem to your machine. .NET framework 2.0 comes with builtin libraries using which you can send/receive sms and in addition could even control the behaviour of your application based ont the replies you receive. same can be done if you go down the line in option 1.

hope this helps :)

It really depends on what wireless carriers you want to be able to send sms to. It seems that every wireless site I've been involved with has had a different way of processing the messages. Some are as simple as sending an email to an email address with the recipient's phone number, and others involve SOAP with handshakes and the whole 9 yards. I agree the best bet to reach the widest range of recipients is to find a third party service. One thing to keep in mind, is you will want to implement CAPTCHA or something similar... very important in this kind of app. Good Luck!

Can you explain me in more details how this work & how u did it sucessfully.


If you can expalin my example of code then better for me


Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.