Any method to search for a specific string in subject

  • Thread starter Thread starter habib
  • Start date Start date
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();
 
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
 
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();
.
 
<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();
.
 
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();

.
.
 
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();

.

.
.
 
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 "
+
.
 
Back
Top