BULK SMS
Email is so old school. New trend is SMS. Send bulk SMS to your customer, This is sample .net code to send bulk SMS using DIDForSale SMS API
eb.config settings: <add key="DidNumber" value="1XXXXXXXXXX" /> <add key="SmsApiBaseUrl" value="https://api.didforsale.com/didforsaleapi/index.php/api/SMS/send/" /> <add key="ApiKey" value="SMjKQ1v67K320e6af48fa9d99b4778132a11ae1d31" /> Coding Description: using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Web; using System.Web.Configuration; using System.Web.Mvc; using System.Net.Security; using System.Security.Cryptography.X509Certificates; namespace DidIVR.Controllers { public class BulkSMSController : Controller { // GET: BulkSMS public string didNumber = WebConfigurationManager.AppSettings["DidNumber"].ToString(); public string apiKey = WebConfigurationManager.AppSettings["ApiKey"].ToString(); public string smsApiBaseUrl = WebConfigurationManager.AppSettings["SmsApiBaseUrl"].ToString(); public ActionResult Index() { var values = System.IO.File.ReadAllLines(@"D:\Raman Saini\DidForSale\DidIVR\DidIVR\DidIVR\App_Data\MobileNumbers.csv").Skip(1).ToArray(); var result = HttpPostRequest(values, "DIDforsale provide SIP, Voice sms and VoIP Solutions."); return this.Content(result); } public string HttpPostRequest(string[] mobileNumber, string text) { string result = string.Empty; //DIDforsale api only accept json data format var httpWebRequest = (HttpWebRequest)WebRequest.Create(smsApiBaseUrl + apiKey); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { var json = "{\"from\":\"" + didNumber + "\",\"to\":" + JsonConvert.SerializeObject(mobileNumber) + ",\"text\":\"" + text + "\"}"; streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); } ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { result = streamReader.ReadToEnd(); } return result; } } }
PS: Sending SMS can be illegal in some states. Its important that you have consent from customer that they want to receive SMS from your company.
New Posts
Learn more about our Products
With so many options to pick from it can often be hard to decide what’s best.
Our plans have been packaged together to give you optimum output.