PDA

View Full Version : کمک.... دریافت SMS



pouya_devil
دوشنبه 30 دی 1387, 14:34 عصر
با سلام به همه دوستان خوبم

من برنامه ی دریافت sms رو مینویسم .... ولی هر کاری میکنم sms رو در برنامه دریافت کنم نمیشه:عصبانی++::عصبانی++::عصب نی++: .... کدی که من نوشتم اینه :

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.MessageInter ception;
using Microsoft.WindowsMobile.PocketOutlook;
using System.Net;

namespace recieve_sms2
{
public partial class Form1 : Form
{

MessageInterceptor[] mi = new MessageInterceptor[2];

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
InterceptSMS();
}
public void InterceptSMS()

{

string[] testFilter ={ "111", "222" };



if (MessageInterceptor.IsApplicationLauncherEnabled("Intercept_Sms"))

{

mi[0] = new MessageInterceptor("Intercept_Sms");

mi[1] = new MessageInterceptor("Intercept_Sms");

}


else

{

for (int i = 0; i < testFilter.Length; i++)

{

//The first array

mi[i] = new MessageInterceptor(InterceptionAction.NotifyAndDel ete, true);

mi[i].MessageCondition = new MessageCondition(MessageProperty.Body,

MessagePropertyComparisonType.StartsWith, testFilter[i], true);



mi[i].MessageReceived += new MessageInterceptorEventHandler(_SMSCatcher_Message Received);

}



}





}



void _SMSCatcher_MessageReceived(object sender, MessageInterceptorEventArgs e)

{

MessageBox.Show(((SmsMessage)e.Message).From.Addre ss, "Message ");//comment

}



}

}


.... حالا اگه کسی هست بتونه کمک کنه یا یه sample کد دیگه بهم بده ممنون میشم....:ناراحت:

pouya_devil
دوشنبه 30 دی 1387, 18:35 عصر
خوب انقد گشتم تا بالاخره خودم پیدا کردم ..... کدشو اینجا میذارم چون میدونم خیلیا دنبالشن ;)


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.MessageInter ception;
using Microsoft.WindowsMobile.PocketOutlook;
using System.Net;
using System.Runtime.InteropServices;

namespace recieve_sms2
{
public partial class Form1 : Form
{


MessageInterceptor _smsinterceptor;


public Form1()
{
InitializeComponent();



}

private void Form1_Load(object sender, EventArgs e)
{

_smsinterceptor = new MessageInterceptor(InterceptionAction.Notify);
_smsinterceptor.MessageCondition = new MessageCondition(MessageProperty.Body, MessagePropertyComparisonType.StartsWith, "Hello");
_smsinterceptor.MessageReceived += new MessageInterceptorEventHandler(smsinterceptor_Mess ageReceived);


}
void smsinterceptor_MessageReceived(object sender, MessageInterceptorEventArgs e)
{

SmsMessage smsMessage = e.Message as SmsMessage;
if (smsMessage != null)
{
Display("Msg: " + smsMessage.From.Address + " - " + smsMessage.Body);

}
}

private void menuItem1_Click(object sender, EventArgs e)
{
Close();
}


void Display(string text)
{

txt_receive.Text += text + "\r\n";//comment

}




}







}

reza6384
دوشنبه 07 بهمن 1387, 20:53 عصر
سلام دوست عزیز.
شما که زحمت کشیدید، لطفا کد ها رو توی تگ کد بذارین و در ضمن یه توضیح راجع به library هایی که ازش توی کدتون استفاده شده بدید.