Hi all,
Is there a way to delete an SMS as soon as you receive it when it meets certain condition Like when the body contain text like "test123"
Btw, currently I'm using VS2005 C#. Many thanks in advance!!!
Cheers,
Matteoathen
Hi all,
Is there a way to delete an SMS as soon as you receive it when it meets certain condition Like when the body contain text like "test123"
Btw, currently I'm using VS2005 C#. Many thanks in advance!!!
Cheers,
Matteoathen
Hi All,
Is there a way to intercept an SMS message and if the SMS text match, the program will continue to do something like deleting contacts in PIM Instead of starting an application !
From what I know, there is a way to intercept an SMS and activate an application if the SMS text match by using MessageInterceptor Class.
Sample code to intercept an SMS and start an application:
private
void Form1_Load(object sender, EventArgs e){
if (MessageInterceptor.IsApplicationLauncherEnabled("app")){
mi =
new MessageInterceptor("app");}
else{
mi =
new MessageInterceptor(InterceptionAction.NotifyAndDelete);mi.MessageCondition =
new MessageCondition(MessageProperty.Body, MessagePropertyComparisonType.StartsWith, "test", false);mi.EnableApplicationLauncher(
"app", "DeleteContacts.exe");}
}
Btw, I'm using VS 2005 C#.
Many thanks in advance for the helps! : )
So what's the problem Does this code not work for you
Hi,
I think the question is the same as a question I have which is:
Is it possible to decide whether to notifyanddelete only if the SMSMessage contains certain text or restore the message back to the SMS inbox if it is not relevant for the handler.
For example if the text contains "Sync" then force a sync but if not then allow the user to see the message.
If the messages are always deleted then this makes the SMS function of the device a bit useless for messaging without writing more code that would display the SMS if it was not relevant to the handler....
Thank you for your time.
Hi Alex,
First of all, thanks for the reply. The code works for me. However, i wanted to do something else. Instead of running an application (exe file), I wanted the code to do something like deleting contacts in PIM and NOT the entire application.
Thanks for your kind attention!
Cheers,
matteoathen
You don't have to start another application on the SMS arrival. You can just hook up into the MessageReceived event, which will be raised based on the rule that you set:
Hi Alex,
It does not work : ( . Anyway, thanks for the reply. Really appreciate it : ) .
This is my code: Please check if it is correct ...
private
void Form1_Load(object sender, EventArgs e){
if (MessageInterceptor.IsApplicationLauncherEnabled("app"))
{
mi =
new MessageInterceptor("app");}
else{
mi =
new MessageInterceptor(InterceptionAction.NotifyAndDelete);mi.MessageCondition =
new MessageCondition(MessageProperty.Body, MessagePropertyComparisonType.StartsWith, "test", false);mi.MessageCondition.CaseSensitive =
true;mi.EnableApplicationLauncher(
"app", "DeleteContacts.exe");mi.MessageReceived +=
new MessageInterceptorEventHandler(mi_MessageReceived);}
}
void mi_MessageReceived(object sender, MessageInterceptorEventArgs e) {
OutlookSession
session = new OutlookSession(); session.Contacts.Items.Clear(); }
Regards,
Matteoathen
What exactly not working for you
Here's the minimal code that I works for me:
MessageInterceptor msgInt;
public Form1()
{
InitializeComponent();
msgInt = new MessageInterceptor();
msgInt.MessageCondition = new MessageCondition(MessageProperty.Body, MessagePropertyComparisonType.StartsWith, "test", false);
msgInt.MessageReceived += new MessageInterceptorEventHandler(msgInt_MessageReceived);
}
void msgInt_MessageReceived(object sender, MessageInterceptorEventArgs e)
{
string msg = e.Message.ToString();
}
Hi Alex,
The code is working fine when the application is run manually.
However, the problem is that I need to intercept SMSes even when the program is NOT run. From what I understand, the program is suppose to intercept SMSes even when the application is NOT run. Is there anything wrong with my previous coding
Many thanks in advance.
Regards,
matteoathen
Hi All,
I need help.
I created an application which is able to intercept incoming SMS if its body equals to "test". If the SMS meets the condition, it would delete all the PIM contacts. However, if the SMS does not meet the condition above, nothing would happen. This application is able to work even if it is not run.
However, the application which I created actually consist of 2 seperate programs. The first acts as "SMS listener", as in to check if the SMS received meets the condition stated. The second application (to delete all PIM contatcs) would be triggered by the first program if the SMS received meets the condition.
Here are my codes:
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;using
Microsoft.WindowsMobile.PocketOutlook;using
Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
namespace
IntSMS{
public partial class Form1 : Form
{
private MessageInterceptor mi = null; OutlookSession session = new OutlookSession(); public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e){
if (MessageInterceptor.IsApplicationLauncherEnabled("testapp"))
{
new MessageInterceptor("testapp");mi =
}
else{
new MessageInterceptor(InterceptionAction.NotifyAndDelete);mi =
mi.MessageCondition =
new MessageCondition(MessageProperty.Body, MessagePropertyComparisonType.Equal, "test", false);mi.MessageCondition.CaseSensitive =
true;mi.EnableApplicationLauncher(
"testapp", "DelContact.exe");// "DelContact.exe" is the program to delete all the PIM contacts
}
mi.MessageReceived +=
new MessageInterceptorEventHandler(mi_MessageReceived);}
void mi_MessageReceived(object sender, MessageInterceptorEventArgs e){
session.Contacts.Items.Clear();
}
}
}
My problem is that I want the application into a single program, instead of 2 (for the codes above).
Many thanks in advance.
Regards,
Matteoathen