Link to home
Start Free TrialLog in
Avatar of DoronAviad
DoronAviadFlag for Israel

asked on

Using Filter with subfolders in Outlook View Control

Hi,

I have developed an MSAccess XP Application and we are using the Outlook View Control
in order to filter email view,

I need to search for all the email from an email address including subfolders (I have inculded code example)

I have 2 questions:
1. This code dosen't filter/search in subFolders how can I do it ?
2. The code is not working with outlook 2007 are there any changes that I have to do ?

Thanks
Doron

sFolder ="inbox"
sRestriction ="[SenderEmailAddress] = " & Chr(34) & sEmailAddress & Chr(34)
With ActiveXCtlOutlook
  .Folder = sFolder
  .Restriction = sRestriction
End With

Open in new window

Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Try:

sRestriction ="[SenderEmailAddress] = '" &  sEmailAddress & "'"

Chris
Avatar of DoronAviad

ASKER

Hi Chris

There is now problem in the sRestriction , but the Restriction is working on the Folder only in this case the "inbox" and not on all the subfolders inside "inboxs"

For example:
If I have 3 Folders inside inbox:

Inbox
  Frineds
  Famely
  Games

if I use the code the filter/restriction will only go for the first level, that is Inbox only
I need to find a way so it can filter the 3 folders inside Inbox as well (Frineds, Famely, Games)

Doron


Okay, apologies I think I understand now, unfortunately as far as I know you cannot pickup subfolders except by potentially doing a recursice search.

I suggest however you keep the question open a while as there a lot of clever people on the site.

Chris
Is there a way to use the DAV: .... in order to filter subfolders as well
Sorry, haven't got a clue!

Chris
Please advise

The problem was not solved
Try using a search folder ... ensure you have a search folder focussing on teh inbox and including the subfoders and then point your filter to whatever you have called the search folder

Chris
Thanks for your answer

But I am using Outlook view control

How can from code make the Outlook View Control use the serach folder and how can I search buy parameters
1. search all unread emails
2. search alll read emails
3. search all forward emails
4. search all followup emails

Doron
As a for example, using the later request:

I have created a search folder called All Messages which I call using:

getsearchfolder("\\personal Folders\Search Folders\All Messages")

And then get a debug print of read/unread mails.

Going back to the original request, getsearchfolder relates to sfolder to which you can apply your own filter.

Chris


Function GetSearchFolder(sf As String) As MAPIFolder
Dim olApp As Outlook.Application
Dim oSearchFolders As Outlook.folders
Dim oFolder As Outlook.MAPIFolder
Dim olkFolder As Folder
Dim colstores As Stores
Dim ostore As Store
Dim strFilter As String
Dim findObj As Object
 
    Set olApp = Outlook.Application
    On Error Resume Next
    Set colstores = olApp.Session.Stores
    For Each ostore In colstores
        Set oSearchFolders = ostore.GetSearchFolders
        For Each oFolder In oSearchFolders
            If LCase(oFolder.FolderPath) = LCase(sf) Then
                Set olkFolder = oFolder
            End If
        Next
    Next
'    Debug.Print olkFolder.Items.count
    Set GetSearchFolder = olkFolder
    strFilter = "[Read] = False"
    Set findObj = GetSearchFolder.Items.Restrict(strFilter)
    Debug.Print findObj.count
    strFilter = "[Read] = True"
    Set findObj = Nothing
    Set findObj = GetSearchFolder.Items.Restrict(strFilter)
    Debug.Print findObj.count
End Function

Open in new window

DoronAviad

Any update?

Chris
Chris

There are no news,
We are still searching for a filter solution to outlook view control
we don't know who to use The solution you wront inside outlook view control

We do not wan't to build manage application that will retrive all the email and filter them and dislay them and etc
we want to use the outlook view control only

can you send me an example of hoe to do the filtring from eithing the outlook view control
That is create a form in Msaccess, add the outlook view control, add 4 buttons for:
1. unread emails
2. read emails
3. send emails
4. followup email
and write some code that will do the job of filtering the outlook view control on the onClick events of every button

Doron
What version of outlook are you using?

Chris
the outlook ActiveX view control is working with all version of outlook from 2000/xp/2003/2007
I need solution for all the version' is is the same ActiveX
ASKER CERTIFIED SOLUTION
Avatar of DoronAviad
DoronAviad
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial