Hi to ALL
Plz help me
i try my best to send sms from visual studio C# to mobile
but i am not sucessfull so far
if any one knows this yhen plz send me procedure as soon as possible
thanx in advance
Good bye.........

Member Avatar for CriticalError

You cannot send text for free, first you need a gateway this is one:
http://www.textlocal.com/

Then you need the api txt local has one for .Net and once you read the documentation you should understand it, hopefully.

//download the "activeXpert mobile messaging toolkit" & install it first...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AxMmCtlLib;
using Demo.DB_Access_Object;

namespace Demo
{
    class SMS
    {
        public string body = "";
        public string address = "";
        public Gsm objGsm = new GsmClass();
        public SmsConstants objSmsConstants = new SmsConstantsClass();

        public void Send()
        {
            Cursor.Current = Cursors.WaitCursor;
            object obj;
            string strMessageReference;
            SmsMessage objSmsMessage = new SmsMessageClass();

            string strName = "HUAWEI Mobile Connect - 3G Modem";

            int iDeviceSpeed;
            iDeviceSpeed = 0;

            objGsm.Open(strName, "", iDeviceSpeed);
            if (objGsm.LastError != 0)
            {
                if (objGsm.LastError == 36101)
                {
                    MessageBox.Show("This SIM requires a PIN code to be entered.");
                }

                objGsm.Close();
                return;
            }

            objSmsMessage.Clear();
            objSmsMessage.ToAddress = "+8801722631766";
            objSmsMessage.Body = "message body...";

            obj = objSmsMessage;
            objGsm.SendSms(ref obj, 10000);
            objSmsMessage = (SmsMessage)obj;
            strMessageReference = objSmsMessage.Reference;

            if (objGsm.LastError == 0)
            {
                ListViewItem item;
                List<string> lsReferences = new List<string>();
                foreach (string strReference in strMessageReference.Split(','))
                {
                    lsReferences.Add(strReference);
                }
            }

            Cursor.Current = Cursors.Default;
            objGsm.Close();
        }

        public void Receive()
        {
            int nFormat;
            SmsMessage objSmsMessage;
            GsmDeliveryReport objDeliveryReport;
            Cursor.Current = Cursors.WaitCursor;
            string strName = "HUAWEI Mobile Connect - 3G Modem";
            int iDeviceSpeed;
            iDeviceSpeed = 0;

            objGsm.Open(strName, "", iDeviceSpeed);

            if (objGsm.LastError == 36101)
            {
                MessageBox.Show("This SIM requires a PIN code to be entered.");
                return;
            }

            int iType = objSmsConstants.GSM_MESSAGESTATE_ALL;
            bool bDelete = false;
            int iStorageType = objSmsConstants.GSM_STORAGETYPE_ALL;

            if (objGsm.LastError == 0)
            {
                objGsm.Receive(iType, bDelete, iStorageType, 10000);
            }

            if (objGsm.LastError != 0)
            {
                objGsm.Close();
                return;
            }

            objSmsMessage = (SmsMessage)objGsm.GetFirstSms();

            while (objGsm.LastError == 0)
            {
                if (objSmsMessage.BodyFormat == objSmsConstants.BODYFORMAT_TEXT)
                {
                    address = objSmsMessage.FromAddress;
                    body = objSmsMessage.Body;
                    //MessageBox.Show(from + "\n" + body);
                }
                else
                {

                }

                objSmsMessage = (SmsMessage)objGsm.GetNextSms();
            }

            objGsm.Close();
            Cursor.Current = Cursors.Default;
        }
    }
}
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.