locked
How to Read SMS from SIM Card and Send SMS using c# in .net RRS feed

  • Question

  • hi,

    I want to read SMS from mobile device connected to PC and Send SMS Via the same mobile.
    I am using VS2003. I am having a GSM modem enabled Mobile connected to my PC. Can anyone send me how to interact with SIM Card like Read SMS, Delete SMS, Send SMS etc.

     

     

     

    Saturday, April 28, 2007 4:19 AM

Answers

  • hey mohan1,

    let's talk here instead. you'll need to download the gsmcomm library to do these stuff. install it and reference the gsmcomm .dll's in your c# application. i'll post some code here, just let me know what processes do you want.

    dave
    Sunday, April 29, 2007 12:19 PM

All replies

  • hey mohan1,

    let's talk here instead. you'll need to download the gsmcomm library to do these stuff. install it and reference the gsmcomm .dll's in your c# application. i'll post some code here, just let me know what processes do you want.

    dave
    Sunday, April 29, 2007 12:19 PM
  • Hi Dave,

    Thank you for response. Is the gsmcomm  libraries are provided by microsoft? is it free to use? what is the trusted URL for the same?

    Could you please provide the sample source code in c# for the same?

    Mohan

    Monday, April 30, 2007 5:08 AM
  • Hi Dave,

    Thank you again. I have downloaded gsmcomm library and able to send SMS. But now I am not able to receive SMS.

    My process is as soon as i received a sms i need to send a reply SMS based on the received SMS and my business logic.

    But the main thing is I must be alert to listen my clients.

    I am using Motorola Phone GSM Modem for my development purpose. What limitation i will face on this if i use the same? what should i do for increasing bottleneck?

    Mohan
    Monday, April 30, 2007 9:47 AM
  • hi Mohan,

    have you perused the gsmcomm sample program? you'll find there's a enable message notification option there. you'll need this to work with the event of receiving a new message. here's a bit of code to help.

    Code Snippet


    // to enable message notification
    this.GSM.MessageReceived += new MessageReceivedEventHandler(comm_MessageReceived);
    this.GSM.EnableMessageNotifications();

    you'll also need the following to show info about the new message:

    private void comm_MessageReceived(object sender, MessageReceivedEventArgs e)
    {
        try
        {
            IMessageIndicationObject obj = e.IndicationObject;
            if (obj is MemoryLocation)
            {
                MemoryLocation loc = (MemoryLocation)obj;
                Output(string.Format("New message received in storage \"{0}\", index {1}.", loc.Storage, loc.Index));
                Output(" ");
                ShowNewMessage(loc.Storage, loc.Index);
                return;
            }
            Output("Error: Unknown notification object!");
        }
        catch (Exception ex)
        {
            Output(ex.Message);
        }
    }

    private void ShowException(Exception ex)
    {
        Output("Error: " + ex.Message + " (" + ex.GetType().ToString() + ")");
        Output("");
    }

    finally, processing the message received:

    private void ShowNewMessage( string msgStorageLocation, int msgStoreIndex )
    {
        DecodedShortMessage message = GSM.ReadMessage(msgStoreIndex, msgStorageLocation);
        PduConverter.SmsDeliverPdu SMSPDU;
        SMSPDU = (PduConverter.SmsDeliverPdu)message.Data;

        //add some code to show the message in a listview or something...

        //you can also add the auto reply code here for example:

        SmsSubmitPdu AutoSend;

        string replymessage = "HI this is Mohan's auto reply message";

        if (SMSPDU.OriginatingAddress.ToString().Length.Equals(13))

        //i limited my phone number to 13 digits to reply only to local numbers here in the philippines.

        you can modify this or remove this condition
        {
            try
            {
                AutoSend = new SmsSubmitPdu(replymessage, SMSPDU.OriginatingAddress, string.Empty);
                GSM.SendMessage(AutoSend);
            }
            catch (Exception ex)
            {
                Output(ex.Message);
            }
        }
    }



    i hope this helps, happy coding!

    dave.


    Tuesday, May 1, 2007 1:52 AM
  • Dave,

    Actually I was trying the same referencing from the demo of GSMComm. But I am getting exception: "The phone does not support one of the required indication modes." in the line:

    this.comm.EnableMessageNotifications();

     

    I am using Motorola RAZR V3i's Motorola Modem. Note that my phone is sending SMS properly. Why the Message is not receieving?

    One more query when I use another phone Modem "HUAWEI Mobile Connect - 3G Modem" in COM3 Port Neither I am able to send or receive SMS only the connection is being success. When I try to send message I get exception like "phone reports generic communication error or syntax error". Interesting thing is when I use HUAWEI's software it is connecting sending and receiving properly.


    Is there any modem compatiability problem?
    I am using VS 2005 in Win 2003 Server OS.

    Thank You

    Wednesday, May 2, 2007 5:57 AM
  • hi mohan,

    we're using different units. i haven't read any compatibility issues yet but i have a teltonika tmodem usb and also tried gsmcomm with a nokia 6020 via infrared. there seemed to be no problem when i used the code.

    i'm using vs team ed for software devs on win xp sp2.

    dave.
    Wednesday, May 2, 2007 3:02 PM
  • Dear Mohan,Im a Sri Lankan  student,So I want to send,read sms from my phone sim using c#.Net.(same to ur requirements )Please help me to develop this one,Can you send me source codes and other relevant details.My email-praveen777@gmail.comThanxPraveen
    Thursday, May 24, 2007 5:30 AM
  • Dear Mohan,Im a Max Rossi student,So I want to send,read sms from my phone sim using c#.Net.Please help me to develop this one,Can you send me source codes and other relevant details.My email-max.rossi@icode.it
    Thursday, May 31, 2007 2:06 PM
  • hi praveen and max,

    try downloading the gsmcomm, it's a library for controlling a gsm modem. it comes with a demo app with source code in c#. feel free to post here if you have questions on using gsmcomm.

    dave.

    Friday, June 1, 2007 1:53 AM
  • Hi Dave

     

    Can you Please forward me url for gsmcomm library download

    on my mail. kalpesh.paradava@gmail.com

    Saturday, June 16, 2007 10:12 AM
  • I'm locking this thread out as it has nothing to do with Smart Devices.

     

    For all seeking GSMComm library URL - find it in 5 seconds or less using your favorite search engine. If you not sure which keyword to use consider using “GSMComm library”.

     

    Monday, June 18, 2007 2:26 AM