Filter outlook 2010 Emails I sent-- but only to one recipient?

I want to search all the mails I sent to "zeev".

enter image description here

But I don't want to include mails which I've sent to "zeev" and "john"

e.g.:

enter image description here

So, I want to find emails which I've sent only to "zeev".

What is the phrase search word which I have to add?


Solution 1:

I don't think it's possible to define your search criteria using Outlook's Advanced Find, however, an alternative way to accomplish your search is to create a custom view.
The custom view described below uses essentially the same SQL DASL query that I used in my other answer of creating a search folder via a macro. I believe the custom view will be easier to for you to implement.

To create the view:

  1. On the View tab, in the Current View group, click Change View, and then click Manage Views.
  2. Click New.
  3. In the Name of new view box, type a name for the view.
  4. In the Type of view box, select 'Table'.
  5. To change where the view is available, select an option under Can be used on, and then click OK.
  6. In the Advanced View Settings: New View dialog box, click Filter.
  7. Select the SQL tab and tick the 'Edit These Criteria Directly' checkbox.
  8. Paste the following DASL query into the textbox:
    "urn:schemas:httpmail:displayto" LIKE 'Zeev%' AND NOT "urn:schemas:httpmail:displayto" LIKE '%;%' AND "urn:schemas:httpmail:displaycc" =''
  9. When finished, click OK.
  10. To use the view immediately, click Apply View.
  11. To return to the standard view, on the View tab, in the Current View group, click Change View, and then click messages.

Solution 2:

The following macro run once will create a Search Folder that persistently shows messages from Sent Items folder that were sent to only a single specified recipient.

In Outlook open the VBA editor using Alt+F11 and paste the code into the editor. Select a message you sent just to your buddy Zeev and then run the macro. You may need to set macro security to low to run the macro.

Sub CreateSearchFolderForOneRecipient()
On Error GoTo Err_CreateSearchFolderForOneRecipient

' Get the email address from a selected message
Dim oMail As Outlook.MailItem
Set oMail = ActiveExplorer.Selection.Item(1)
strSearchFolderName = "Msgs sent only to " & oMail.To

If oMail.To = "" Then
    Exit Sub
ElseIf InStr(1, oMail.To, ";") > 0 Then
    Err.Raise Number:=vbObjectError + 1000, _
        Description:="Selected message must have only 1 recipient in To: field"
End If

Dim strDASLFilter As String
' The trick to identifying messages sent to multiple recipients is the semi-colon ; delimiter.
' Semicolon can be searched using SQL DASL syntax but not in the Advanced Search form GUI
' Description of filter
' Line 1: Messages sent to specified recipient
' Line 2: 'To' field cannot contain semicolon
' LIne 3: 'CC' field must be empty
strDASLFilter = Chr(34) & "urn:schemas:httpmail:displayto" & Chr(34) & " = '" & oMail.To & "'" _
    & " AND NOT " & Chr(34) & "urn:schemas:httpmail:displayto" & Chr(34) & " LIKE '%;%'" _
    & " AND " & Chr(34) & "urn:schemas:httpmail:displaycc" & Chr(34) & " = ''"

Dim strScope As String
strScope = "'Sent Items'"

Dim objSearch As Search
Set objSearch = Application.AdvancedSearch(Scope:=strScope, Filter:=strDASLFilter, _
    SearchSubFolders:=True, Tag:="SearchFolder")

' Save the search results to a searchfolder
objSearch.Save (strSearchFolderName)

Set objSearch = Nothing

Exit Sub


Err_CreateSearchFolderForOneRecipient:
    MsgBox "Error # " & Err.Number & " : " & Error(Err)

End Sub

Macro is a modified version of code from How to create an Outlook search folder using VBA