Use ASPSnippets SMS API (Site2SMS) in Console Application using C# .Net

Last Reply on Sep 22, 2015 02:34 AM By dharmendr

Posted on Sep 16, 2015 12:18 AM

Will the Site2SMS code work with a console application using COM1? If it can be use send me the code snipped, please.

Thanks

Posted on Sep 20, 2015 06:24 AM

Hi ses,

Here i have created the console application for sending sms using ASPSnippets SmsAPI.

Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ASPSnippets.SmsAPI;

namespace Site2SMS
{
    class Sms
    {
        public static void sendSms(string mashapeKey, string moNumber, string password, string recipientNumber, string message)
        {
            SMS.APIType = SMSGateway.Site2SMS;
            SMS.MashapeKey = mashapeKey;
            SMS.Username = moNumber;
            SMS.Password = password;
            if (recipientNumber.IndexOf(",") == -1)
            {
                SMS.SendSms(recipientNumber, message);
            }
            else
            {
                List<string> numbers = recipientNumber.Split(',').ToList();
                SMS.SendSms(numbers, message);
            }
        }
        static void Main(string[] args)
        {
            string mashapeKey;
            string moNumber;
            string password;
            string recipientNumber;
            string message;
            Console.Write("Enter MashapeKey:\t");
            mashapeKey = Console.ReadLine();
            Console.Write("Enter Login Mobile Number:\t");
            moNumber = Console.ReadLine();
            Console.Write("Enter Password:\t");
            password = Console.ReadLine();
            Console.Write("Enter Recipient Mobile Number:\t");
            recipientNumber = Console.ReadLine();
            Console.Write("Enter Message:\t");
            message = Console.ReadLine();
            Sms.sendSms(mashapeKey,moNumber, password, recipientNumber, message);
        }
    }
}

 


Posted on Sep 22, 2015 02:34 AM

Hi ses,

Please refer the below articles for register with Site2SMS and getting mashape key.

How to generate Mashape API Key

Send free SMS in ASP.Net using C# and VB.Net