Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / September 2003

Tip: Looking for answers? Try searching our database.

Any method to search for a specific string in subject

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
habib - 12 Sep 2003 18:25 GMT
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();
Sue Mosher [MVP] - 12 Sep 2003 18:55 GMT
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.
Signature

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
    http://www.outlookcode.com/jumpstart.aspx 

> Hi,
>
[quoted text clipped - 29 lines]
> outlookApp = null;
> WScript.Quit();
habib - 12 Sep 2003 19:40 GMT
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,
>>
[quoted text clipped - 31 lines]
>>
>.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.