Automating Outlook find.

Dan_T

Registered User.
Local time
Today, 19:11
Joined
Jul 14, 2004
Messages
116
Hi,

I have a requirement to find emails from a particular sender. The way I would like to do it is to create an instance of outlook and automate the find function. Therefore displaying the found emails within outlook so the user can carry on from there replying or whatever to particular emails.

So far I have got to the point where I can open the inbox and select the Find commandbar button on the standard toolbar. Am I going about this the right way?

Here is the code that has got me the closest so far.

___________________________________________________
Function fFindEmails()

Dim outApp As New Outlook.Application
Dim nsp As Outlook.NameSpace
Dim mpfInbox As Outlook.MAPIFolder
Dim expInbox As Outlook.Explorer

Set nsp = outApp.GetNamespace("MAPI")
Set mpfInbox = nsp.GetDefaultFolder(olFolderInbox)
Set expInbox = mpfInbox.GetExplorer

With expInbox
.CommandBars.Item("Standard").Controls("Find").Execute
.Activate
End With

End Function
______________________________________________________

The code also has the failings in that the .execute part turns Find on and off and not just on.

Any pointers would be much appreciated or suggestions on other methods to resolve this one.

Many Thanks

Dan
 
I don't know is this info will be of any use, but you can actually embed the users Outlook 'InBox' into an Access form, at least in Outlook 2003. The ActiveX is called the 'MIcrosoft Office Outlook View Control'.

When it's embedded you can right click any email received, select 'Find All > Messages from Sender, and the Advanced Find window pops up with all the Senders emails.

You can also double-click any email to send a reply.
 
Last edited:
Hi thanks for the reply. I was hoping to have a restricted list of emails to a criteria in outlook rather than view an inbox and search from there. From the option you suggested can I summise that I still need to manually perform the search? It's this I want to avoid.

I have since found this out from MS.

"A: You cannot programmatically use the Find or Advanced Find features in Outlook, but you can use the Find method in the Outlook object model to retrieve a single item based on the contents of one or more fields. You can also use the Restrict method to retrieve a set of items that match certain criteria. For additional information about how to use the Find/ and Restrict methods, click the following article number to view the article in the Microsoft Knowledge Base:"

I have used the find and restrict methods to get the required items. What I wanted to do though was display these items within Outlook rather than in Access. I didn't want to build a list of emails for the user to see I wanted a list of the actual emails.
 
Meltdown. Actually with further thought your idea may well be the answer. I have been playing around with it and it works. There is one but which you or someone may be able to help me with. Its the speed the search is conducted. Possibly a question for the outlook forum really. The issue is that currently emails (and there are a lot of them) are stored in a myriad of folders. If they were stored in one folder would the search performance increase?
 

Users who are viewing this thread

Back
Top Bottom