Solved

outlook search

Posted on 2002-04-09
3
169 Views
Last Modified: 2010-05-02
I have to perform search on the outlook.pst files programmatically.
I have to search the subject and body of the mails as it is provided in microsoft outlook itself.
for eg if i have a search criteria like
"welcome town"
if the subject of my first mail in outlook is
"welcome" and the second one has "welcome hello town"
then only the second one should come
i have used restrict method of outlook 9.0 object library but i get the result only if i give the whole subject as search string ie
"welcome hello town"
Waiting for the reply.Thanks!!!!!
Urgent...
0
Comment
Question by:shivanit
3 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 15 total points
ID: 6927719
Hi shivanit,

Here is an example:

Private Sub Command3_Click()
    Dim iOutlook As Outlook.Application
    Dim myitem As Outlook.MailItem
    Dim myFolder As Outlook.MAPIFolder
    Dim myAttach As Outlook.Attachment
    Dim SearchString As String
   
    SearchString = "Welcome"
    Set iOutlook = New Outlook.Application
   
    Set myFolder = iOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)

    List1.Clear
    For i = 1 To myFolder.Items.Count
        Set myitem = myFolder.Items(i)
        If InStr(1, myitem.Subject, SearchString) > 0 Then 'If InStr(1, myitem.Subject, SearchString) = 1 Then 'Perform Like% method
            List1.AddItem myitem.SenderName & " " & myitem.Subject
            DoEvents
        End If
    Next i
    Set myitem = Nothing
    Set myFolder = Nothing
    Set iOutlook = Nothing
End Sub

Hope this help
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7643114
Hi shivanit,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept ryancys's comment(s) as an answer.

shivanit, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7673317
Moving to the PAQ

kb
Experts Exchange Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now