专注

导航

windows mobile 手机短信(.NET)

说白了,Windows Mobile接收发送手机短信实在是简单,因为有Microsoft.WindowsMobile.PocketOutlook类,所以,基本上发送接受短信就是编写内容,按照类中提供方法的参数格式,一个个填写进去即可。

 

   1:  //发送短信
   2:  SmsMessage smsSend = new SmsMessage(手机号码, 短信内容);
   3:  smsSend.Send();
   4:  //接收短信
   5:  SmsMessage msg = e.Message as Microsoft.WindowsMobile.PocketOutlook.SmsMessage;
   6:  textBox1.Text = msg.From.Address;
   7:  textBox2.Text = msg.Body;  

为了自动接收短信,当然需要将上面的方法委托一下即可。

   1:          private void mMessageInterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e)
   2:          {
   3:              if (e.Message is Microsoft.WindowsMobile.PocketOutlook.SmsMessage)
   4:              {
   5:   
   6:                  Microsoft.WindowsMobile.PocketOutlook.SmsMessage msg = e.Message as Microsoft.WindowsMobile.PocketOutlook.SmsMessage;
   7:                  textBox1.Text = msg.From.Address;
   8:                  textBox2.Text = msg.Body;          
   9:              }
  10:          }

在窗口的Load处写上

Microsoft.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor mMessageInterceptor = new MessageInterceptor();
            mMessageInterceptor.MessageReceived += new MessageInterceptorEventHandler(mMessageInterceptor_MessageReceived);

posted on 2011-11-14 13:27  陈啊M  阅读(242)  评论(0编辑  收藏  举报