Can I send SMS messages from a C # application?

I want to create a program that will allow me to send SMS messages directly from a C # application. I intend to create an "Automatic Meeting Reminder" system that automatically sends SMS messages to recipients' mobile phones, notifying them of an upcoming appointment.

Can anyone advise on how I would implement this type of functionality since I have no experience with Mobile and Mobile with desktop applications.

My carrier is EE (if that helps?)

Any help would be greatly appreciated.

+5


source to share


4 answers


Most major carriers offer email for text services. The program can use email to send SMS messages. For example:

to send a letter

var message = new MailMessage();
message.From = new MailAddress("sender@foo.bar.com");

message.To.Add(new MailAddress("5551234567@txt.att.net"));//See carrier destinations below
//message.To.Add(new MailAddress("5551234568@txt.att.net"));

//message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
message.Subject = "This is my subject";
message.Body = "This is the content";

var client = new SmtpClient();
client.Send(message);

      

Carrier destinations



  • ATT: Compose a new email and use the recipient's 10-digit phone number followed by @ txt.att.net. For example, 5551234567@txt.att.net.
  • Verizon: Likewise, ##@vtext.com
  • Sprint: ##@messaging.sprintpcs.com
  • TMobile: ##@tmomail.net
  • Virgin Mobile: ##@vmobl.com
  • Nextel: ##@messaging.nextel.com
  • Promotion: ##@myboostmobile.com
  • Alltel: ##@message.alltel.com
  • EE: ##@mms.ee.co.uk (may support sending unanswered)

alternatives

  • There are providers that provide SMS messaging service via API
+6


source


Twilio has a C # helper library that lets you do this.

Here is the code you need to send a text message with the library:



using System;
using Twilio;
class Example
{
  static void Main(string[] args)
  {
    // Find your Account Sid and Auth Token at twilio.com/user/account
    string AccountSid = "{{ account_sid }}";
    string AuthToken = "{{ auth_token }}";

    var twilio = new TwilioRestClient(AccountSid, AuthToken);
    var message = twilio.SendMessage("+14158141829", "+14159352345", "This text message was sent with code!");

    Console.WriteLine(message.Sid);
  }
}

      

Disclaimer: I work for Twilio.

+4


source


You can send sms in various ways

  • Using a GSM modem
  • Using the web service
  • Using endpoints provided by the provider service

You can understand the basic logic for each of the above points through the link given below and try to achieve it in your code.

http://www.codeproject.com/Articles/19023/Sending-SMS-using-NET

You need to instantiate the sms engine in the constructor of the form like this.

  public partial class Form1 : Form
    {
        SMSCOMMS SMSEngine;

        public Form1()
        {

                    SMSEngine = new SMSCOMMS("COM1");



            InitializeComponent();
            SMSEngine.Open();
        }

        private void button1_Click(object sender, EventArgs e)
        {
          SMSEngine.SendSMS("919888888888","THIS IS YOUR MESSAGE");
          SMSEngine.Close();
        }
    }
}

      

+3


source


using System;
using System.Collections.Specialized;
using System.Net;

using (WebClient client = new WebClient())
{
  byte[] response = client.UploadValues("http://textita.com/text", new 
  NameValueCollection() {
    { "phone", "9087938341" },
    { "message", "Hello world" },
    { "key", "textita" },
  });

  string result = System.Text.Encoding.UTF8.GetString(response);
}

      

0


source







All Articles