Reputation: 351
I'm looking to build a program that would allow me to send SMS messages directly from the C# Application. I intend to build an 'Automatic Appointment Reminder' system that would automatically send SMS messages to recipients' mobile phones notifying them of their upcoming appointment.
Could anyone advise on how I would implement this type of feature as I have no experience in 'Mobile Communications' and mobile connectivity with desktop applications.
My carrier is EE (If that helps?)
Upvotes: 22
Views: 86510
Reputation: 1
Ozeki's C# sms api provides feedback in the form of events. This is great because other SMS api-s don't offer delivered to handset reports or any other real feedback about what happened to your SMS. Here is the code.
using System; using OZX;
namespace OzekiConsoleClient { class Program { static OzxClient Client;
static void Main(string[] args)
{
Client = new OzxClient();
Client.AutoReconnect = true;
Client.OnMessageAcceptedForDelivery += Client_OnMessageAcceptedForDelivery;
Client.OnMessageNotAcceptedForDelivery += Client_OnMessageNotAcceptedForDelivery;
Client.OnMessageSubmitSuccess += Client_OnMessageSubmitSuccess;
Client.OnMessageSubmitFailed += Client_OnMessageSubmitFailed;
Client.OnMessageDeliverySuccess += Client_OnMessageDeliverySuccess;
Client.OnMessageDeliveryFailed += Client_OnMessageDeliveryFailed;
Client.OnMessageViewed += Client_OnMessageViewed;
Client.OnConnected += Client_OnConnected;
Client.OnDisconnected += Client_OnDisconnected;
Client.Connect("127.0.0.1",9580,"testuser","testpass");
}
static void Client_OnConnected(object sender, EventArgs e)
{
Console.WriteLine("Successfully connected.");
var msg = new OzxMessage();
msg.ToAddress = "+447958448798";
msg.Text = "Hello world";
Console.WriteLine("Sending message. ID: "+msg.ID);
Client.Send(msg);
}
}
}
You can also use this code to send an SMS through an Android Mobile instead of subscribing for an On-line SMS service.
Disclaimer: I work for Ozeki.
Upvotes: -1
Reputation: 1244
Twilio has a C# helper library that will let you do this.
Here's the code you'd 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.
Upvotes: 12
Reputation: 1
You can send sms through variety of ways
You can understand the basic logic for each of the above points through the link provided below and try to achieve that in your code.
http://www.codeproject.com/Articles/19023/Sending-SMS-using-NET
You need to create an instance of the sms engine in your form constructor 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();
}
}
}
Upvotes: 6
Reputation: 44295
Most major carriers offer an email to text service. The program can use email to send an SMS message. For example:
var message = new MailMessage();
message.From = new MailAddress("[email protected]");
message.To.Add(new MailAddress("[email protected]"));//See carrier destinations below
//message.To.Add(new MailAddress("[email protected]"));
//message.CC.Add(new MailAddress("[email protected]"));
message.Subject = "This is my subject";
message.Body = "This is the content";
var client = new SmtpClient();
client.Send(message);
Upvotes: 25