监视来到的短消息例子
来源:互联网 发布:行业应用类软件 编辑:程序博客网 时间:2024/04/29 10:04
监视来到的短消息例子
这个例子是按照监视来到的短消息,然后按照提取短消息的内容,我们可以按照里面的内容
让程序做些动作,本个例子是发送你的未读的SMS,MAIL,MMS的数量,由此可以推开得到一些
其他的应用。。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile;
using Microsoft.WindowsMobile.Telephony;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
using Microsoft.WindowsMobile.Status;
//using Microsoft.WindowsMobile.Status.SystemState;
namespace AppDemo
…{
public partial class Form1 : Form
…{
private OutlookSession AppSession;
private OutlookSession SmsSession;
private AppointmentCollection AppAppts;
private ListViewItem lviAppt;
private ListViewItem smsItem;
private MessageInterceptor interceptor;
public Form1()
…{
InitializeComponent();
interceptor = new MessageInterceptor(InterceptionAction.Notify);
interceptor.MessageReceived += new MessageInterceptorEventHandler(interceptor_MessageReceived);
}
private void button1_Click(object sender, EventArgs e)
…{
AppSession = new OutlookSession();
AppAppts = AppSession.Appointments.Items;
foreach (Appointment appt in AppAppts)
…{
lviAppt = new ListViewItem();
lviAppt.Text = appt.Start.ToShortDateString();
lviAppt.SubItems.Add(appt.Start.ToShortTimeString());
lviAppt.SubItems.Add(appt.Subject);
lvAppt.Items.Add(lviAppt);
}
AppSession.Dispose();
}
private void button2_Click(object sender, EventArgs e)
…{
Phone phone = new Phone();
try
…{
phone.Talk(“13425173242“);
}
catch
…{
MessageBox.Show(“Can’t Dailing…“);
}
}
private void button3_Click(object sender, EventArgs e)
…{
SmsSession = new OutlookSession();
//SmsAccount sms ;
smsItem = new ListViewItem();
smsItem.Text = (String)SmsSession.SmsAccount.Name;
lvAppt.Items.Add(smsItem);
}
private void button4_Click(object sender, EventArgs e)
…{
if (btnActivate.Text.IndexOf(“Activate“) != -1)
…{
interceptor = new MessageInterceptor(InterceptionAction.Notify);
interceptor.MessageReceived += new MessageInterceptorEventHandler(interceptor_MessageReceived);
btnActivate.Text = “Deactivate“;
}
if (btnActivate.Text.IndexOf(“Deactivate“) != -1)
…{
interceptor.Dispose();
interceptor = null;
btnActivate.Text = “Activate“;
}
interceptor_MessageReceived((object)sender ,( MessageInterceptorEventArgs )e );
}
void interceptor_MessageReceived(object sender, MessageInterceptorEventArgs e)
…{
SmsMessage sms = (SmsMessage)e.Message;
string strFrom = sms.From.Address;
string strMessageText = sms.Body.Trim().ToLower();
bool bGotCommand = false;
string strReplyMessage = “”;
switch (strMessageText)
…{
case “getunreadsms“:
strReplyMessage = “Unread SMS: “+SystemState.MessagingSmsUnread;
bGotCommand = true;
break;
case “getunreademail“:
strReplyMessage = “Unread Email: “+SystemState.MessagingTotalEmailUnread;
bGotCommand = true;
break;
case “getunreadmms“:
strReplyMessage = “Unread MMS: “+SystemState.MessagingMmsUnread;
bGotCommand = true;
break;
}
if (bGotCommand == true)
…{
SmsMessage replySMS = new SmsMessage();
replySMS.To.Add(new Recipient(strFrom));
replySMS.Body = strReplyMessage;
replySMS.Send();
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile;
using Microsoft.WindowsMobile.Telephony;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
using Microsoft.WindowsMobile.Status;
//using Microsoft.WindowsMobile.Status.SystemState;
namespace AppDemo
…{
public partial class Form1 : Form
…{
private OutlookSession AppSession;
private OutlookSession SmsSession;
private AppointmentCollection AppAppts;
private ListViewItem lviAppt;
private ListViewItem smsItem;
private MessageInterceptor interceptor;
public Form1()
…{
InitializeComponent();
interceptor = new MessageInterceptor(InterceptionAction.Notify);
interceptor.MessageReceived += new MessageInterceptorEventHandler(interceptor_MessageReceived);
}
private void button1_Click(object sender, EventArgs e)
…{
AppSession = new OutlookSession();
AppAppts = AppSession.Appointments.Items;
foreach (Appointment appt in AppAppts)
…{
lviAppt = new ListViewItem();
lviAppt.Text = appt.Start.ToShortDateString();
lviAppt.SubItems.Add(appt.Start.ToShortTimeString());
lviAppt.SubItems.Add(appt.Subject);
lvAppt.Items.Add(lviAppt);
}
AppSession.Dispose();
}
private void button2_Click(object sender, EventArgs e)
…{
Phone phone = new Phone();
try
…{
phone.Talk(“13425173242“);
}
catch
…{
MessageBox.Show(“Can’t Dailing…“);
}
}
private void button3_Click(object sender, EventArgs e)
…{
SmsSession = new OutlookSession();
//SmsAccount sms ;
smsItem = new ListViewItem();
smsItem.Text = (String)SmsSession.SmsAccount.Name;
lvAppt.Items.Add(smsItem);
}
private void button4_Click(object sender, EventArgs e)
…{
if (btnActivate.Text.IndexOf(“Activate“) != -1)
…{
interceptor = new MessageInterceptor(InterceptionAction.Notify);
interceptor.MessageReceived += new MessageInterceptorEventHandler(interceptor_MessageReceived);
btnActivate.Text = “Deactivate“;
}
if (btnActivate.Text.IndexOf(“Deactivate“) != -1)
…{
interceptor.Dispose();
interceptor = null;
btnActivate.Text = “Activate“;
}
interceptor_MessageReceived((object)sender ,( MessageInterceptorEventArgs )e );
}
void interceptor_MessageReceived(object sender, MessageInterceptorEventArgs e)
…{
SmsMessage sms = (SmsMessage)e.Message;
string strFrom = sms.From.Address;
string strMessageText = sms.Body.Trim().ToLower();
bool bGotCommand = false;
string strReplyMessage = “”;
switch (strMessageText)
…{
case “getunreadsms“:
strReplyMessage = “Unread SMS: “+SystemState.MessagingSmsUnread;
bGotCommand = true;
break;
case “getunreademail“:
strReplyMessage = “Unread Email: “+SystemState.MessagingTotalEmailUnread;
bGotCommand = true;
break;
case “getunreadmms“:
strReplyMessage = “Unread MMS: “+SystemState.MessagingMmsUnread;
bGotCommand = true;
break;
}
if (bGotCommand == true)
…{
SmsMessage replySMS = new SmsMessage();
replySMS.To.Add(new Recipient(strFrom));
replySMS.Body = strReplyMessage;
replySMS.Send();
}
}
- 监视来到的短消息例子。
- 监视来到的短消息例子
- 监视RMAN通道例子
- 短消息系统的调整
- 手机的短消息实现
- 发给父母的“短消息”
- 发短消息的程序
- 短消息的暴利时代
- 短消息
- 暖暖的短消息(集锦)
- 下一代社区短消息的变化
- GSM 发送短消息的基本知识
- 暖暖的短消息(集锦)
- 短消息发送的SQL过程
- 类似iphone的短消息效果
- 来到疯人院的原因
- 来到这里的人
- 来到csdn的感受
- windows相关命令
- 为什么EJB组件本身不允许设定隔离级别?
- 网络环境管理
- 设计EJB中的事务会话。(事务失败后的处理)
- URL重写指南
- 监视来到的短消息例子
- 菜鸟博客
- Jeep的胜利!!Jeep牧马人带领人类到达越野车新高度
- c#.net常用函数列表.txt -转
- 将serv-u用ODBC的方式将用户添加至SQL数据库中.附域离线的解决
- 我的博客生涯
- DIV+CSS网页布局实例
- 浅析字符集以及PHP+Mysql4.1的乱码问题
- The SWT FAQ 中文(12)