Click here to Skip to main content
13,293,178 members (38,893 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all

I am searching outlook sent items using advanced search method
namespace using Outlook = Microsoft.Office.Interop.Outlook;

Outlook._NameSpace olNs;
Outlook.MAPIFolder oSents;
Outlook.Items oItems;
Outlook._Application OutlookApp = new Outlook.Application();
Outlook.Results advancedSearchResults = null;
Outlook.Search advancedSearch = null;
olNs = olApp.GetNamespace("MAPI");
oSents = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
string scope = "'" + oSents.FolderPath + "'";

string ToAddress= "";
string advancedSearchTag = "Our first advanced search in Outlook";
string filter = "urn:schemas:httpmail:to LIKE \'%" + ToAddress+ "%\'";

advancedSearch = OutlookApp.AdvancedSearch(scope, filter, false, advancedSearchTag);
advancedSearchResults = advancedSearch.Results;

for (int count = advancedSearchResults.Count; count >= 1; count--)
        oMICopy = (Outlook._MailItem)advancedSearchResults[count];
        sAddress = oMICopy.Recipients[1].Address.ToString();

But i am not getting any items from sentItems folder.
It is showing advancedSearchResults.Count=0
how to seach SentMailItems of outlook with to-mail address.
Posted 18-Sep-12 1:59am
Updated 23-Oct-16 18:07pm
BillWoodruff 24-Sep-12 9:34am
Have all the sent messages received been sent from OutLook/Exchange ?

If you enumerate the contents of the 'oSents variable ... assuming that it does hold a valid reference to the SentItems folder of Type Outlook.MAPIFolder ... what do you find ?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You could try and put in double quotes around the schema. Also I don't see code for specifying the callback method that will be used when the advance search completes?

This link may help.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171207.1 | Last Updated 23 Oct 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100