Any method to search for a specific string in subject

H

habib

Hi,

Any one know if there's method that search for a specific
string in the subject (not the exact subject)?

I tried Find method which give results only if the string
to look for and the subject match exactly.

I tried AdvancedSearch but I am getting an error, anything
wrong with my following code ?


/********************************/
var outlookApp = null;
var nameSpace = null;
var mailFolder = null;
var mailItem = null;
var subject = 'I will be'
var filter = "[Subject] = " + subject

outlookApp = WScript.CreateObject("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.Find(filter);

//filter = "urn:schemas:mailheader:subject LIKE " +
subject + "%"
//mailItem = outlookApp.AdvancedSearch("Inbox", filter);

mailItem.display(0);

WScript.DisconnectObject(outlookApp);
outlookApp = null;
WScript.Quit();
 
S

Sue Mosher [MVP]

Looks like you're missing a %. The search string should be:

"urn:schemas:mailheader:subject LIKE %" & subject & "%"

AdvancedSearch cannot be used from a script, however, since it requires monitoring of related events to know when the search has completed.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
H

habib

So any solution ?
thanks.

-----Original Message-----
Looks like you're missing a %. The search string should be:

"urn:schemas:mailheader:subject LIKE %" & subject & "%"

AdvancedSearch cannot be used from a script, however,
since it requires monitoring of related events to know
when the search has completed.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers



Hi,

Any one know if there's method that search for a specific
string in the subject (not the exact subject)?

I tried Find method which give results only if the string
to look for and the subject match exactly.

I tried AdvancedSearch but I am getting an error, anything
wrong with my following code ?


/********************************/
var outlookApp = null;
var nameSpace = null;
var mailFolder = null;
var mailItem = null;
var subject = 'I will be'
var filter = "[Subject] = " + subject

outlookApp = WScript.CreateObject ("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.Find(filter);

//filter = "urn:schemas:mailheader:subject LIKE " +
subject + "%"
//mailItem = outlookApp.AdvancedSearch("Inbox", filter);

mailItem.display(0);

WScript.DisconnectObject(outlookApp);
outlookApp = null;
WScript.Quit();
.
 
D

Dmitry Streblechenko

<shameless_plug>
Or you can use MAPITable object in Redemption which exposes FL_SUBSTRING
fuzzy level:
http://www.dimastr.com/redemption/mapitable.htm#rescontent
</shameless_plug>

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


From a script? Do a For Each ... Next loop on all the items in the folder
and test each subject with Instr()
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers


habib said:
So any solution ?
thanks.

-----Original Message-----
Looks like you're missing a %. The search string should be:

"urn:schemas:mailheader:subject LIKE %" & subject & "%"

AdvancedSearch cannot be used from a script, however,
since it requires monitoring of related events to know
when the search has completed.
Hi,

Any one know if there's method that search for a specific
string in the subject (not the exact subject)?

I tried Find method which give results only if the string
to look for and the subject match exactly.

I tried AdvancedSearch but I am getting an error, anything
wrong with my following code ?


/********************************/
var outlookApp = null;
var nameSpace = null;
var mailFolder = null;
var mailItem = null;
var subject = 'I will be'
var filter = "[Subject] = " + subject

outlookApp = WScript.CreateObject ("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.Find(filter);

//filter = "urn:schemas:mailheader:subject LIKE " +
subject + "%"
//mailItem = outlookApp.AdvancedSearch("Inbox", filter);

mailItem.display(0);

WScript.DisconnectObject(outlookApp);
outlookApp = null;
WScript.Quit();
.
 
H

habib

Thanks for your help.

Could be possible to seach in subfolder of the Inbox
Folder for example ?
Could be possible to know how many subfolder a Folder
contains ?

Thanks in advance.

-----Original Message-----
From a script? Do a For Each ... Next loop on all the
items in the folder and test each subject with Instr()
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers


So any solution ?
thanks.

-----Original Message-----
Looks like you're missing a %. The search string
should
be:
"urn:schemas:mailheader:subject LIKE %" & subject & "%"

AdvancedSearch cannot be used from a script, however,
since it requires monitoring of related events to know
when the search has completed.
Hi,

Any one know if there's method that search for a specific
string in the subject (not the exact subject)?

I tried Find method which give results only if the string
to look for and the subject match exactly.

I tried AdvancedSearch but I am getting an error, anything
wrong with my following code ?


/********************************/
var outlookApp = null;
var nameSpace = null;
var mailFolder = null;
var mailItem = null;
var subject = 'I will be'
var filter = "[Subject] = " + subject

outlookApp = WScript.CreateObject ("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.Find(filter);

//filter = "urn:schemas:mailheader:subject LIKE " +
subject + "%"
//mailItem = outlookApp.AdvancedSearch("Inbox", filter);

mailItem.display(0);

WScript.DisconnectObject(outlookApp);
outlookApp = null;
WScript.Quit();

.
.
 
H

habib

Any example to get the number of folders collection for a
specific folder?

thx.

-----Original Message-----
Each folder has a Folders collection.

Thanks for your help.

Could be possible to seach in subfolder of the Inbox
Folder for example ?
Could be possible to know how many subfolder a Folder
contains ?

Thanks in advance.

-----Original Message-----
From a script? Do a For Each ... Next loop on all the
items in the folder and test each subject with Instr()
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers


So any solution ?
thanks.


-----Original Message-----
Looks like you're missing a %. The search string should
be:

"urn:schemas:mailheader:subject LIKE %" & subject & "%"

AdvancedSearch cannot be used from a script, however,
since it requires monitoring of related events to know
when the search has completed.

Hi,

Any one know if there's method that search for a
specific
string in the subject (not the exact subject)?

I tried Find method which give results only if the
string
to look for and the subject match exactly.

I tried AdvancedSearch but I am getting an error,
anything
wrong with my following code ?


/********************************/
var outlookApp = null;
var nameSpace = null;
var mailFolder = null;
var mailItem = null;
var subject = 'I will be'
var filter = "[Subject] = " + subject

outlookApp = WScript.CreateObject
("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.Find(filter);

//filter = "urn:schemas:mailheader:subject LIKE " +
subject + "%"
//mailItem = outlookApp.AdvancedSearch("Inbox", filter);

mailItem.display(0);

WScript.DisconnectObject(outlookApp);
outlookApp = null;
WScript.Quit();

.

.
.
 
H

habib

Its working.

thanks.

-----Original Message-----
Any example to get the number of folders collection for a
specific folder?

thx.

-----Original Message-----
Each folder has a Folders collection.

Thanks for your help.

Could be possible to seach in subfolder of the Inbox
Folder for example ?
Could be possible to know how many subfolder a Folder
contains ?

Thanks in advance.


-----Original Message-----
From a script? Do a For Each ... Next loop on all the
items in the folder and test each subject with Instr()
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers


So any solution ?
thanks.


-----Original Message-----
Looks like you're missing a %. The search string
should
be:

"urn:schemas:mailheader:subject LIKE %" & subject & "%"

AdvancedSearch cannot be used from a script, however,
since it requires monitoring of related events to know
when the search has completed.

Hi,

Any one know if there's method that search for a
specific
string in the subject (not the exact subject)?

I tried Find method which give results only if the
string
to look for and the subject match exactly.

I tried AdvancedSearch but I am getting an error,
anything
wrong with my following code ?


/********************************/
var outlookApp = null;
var nameSpace = null;
var mailFolder = null;
var mailItem = null;
var subject = 'I will be'
var filter = "[Subject] = " + subject

outlookApp = WScript.CreateObject
("Outlook.Application");
nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.Find(filter);

//filter = "urn:schemas:mailheader:subject
LIKE "
+
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top