在c#中收到短信

时间:2013-01-08 08:09:05

标签: c# sms gsm

我使用此代码接收短信,但有时它不起作用,这意味着它无法理解短信接收。每次工作时我能做什么:

CommSetting.comm.MessageReceived+=new MessageReceivedEventHandler(comm_MessageReceived);

private void comm_MessageReceived(object sender, GsmComm.GsmCommunication.MessageReceivedEventArgs e)
{
    Cursor.Current = Cursors.WaitCursor;
    string storage = GetMessageStorage();

    DecodedShortMessage[]messages=CommSetting.comm.ReadMessages(PhoneMessageStatus.ReceivedUnread , storage);

    foreach(DecodedShortMessage message in messages)
    {
        Output(string.Format("Message status = {0}, Location = {1}/{2}",
                             StatusToString(message.Status),
                             message.Storage, message.Index));
        ShowMessage(message.Data);
        Output("");
    }

    Output(string.Format("{0,9} messages read.", messages.Length.ToString()));
    Output("");
}

0 个答案:

没有答案