Click here to Skip to main content
Sign Up to vote bad
good
See more: C#4.0
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= "prasanna@zqa.com";
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--)
{
    try
    {
        oMICopy = (Outlook._MailItem)advancedSearchResults[count];
        sAddress = oMICopy.Recipients[1].Address.ToString();
    }
    catch
    {
        continue;
    }
 }      
    
 

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 0:59am
Edited 24-Feb-13 18:46pm

Comments
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 ?

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Christian Graus 393
1 Prasad_Kulkarni 390
2 Michael Haephrati 390
3 OriginalGriff 320
4 CPallini 279
0 Sergey Alexandrovich Kryukov 6,824
1 Prasad_Kulkarni 3,671
2 _Amy 3,312
3 OriginalGriff 3,309
4 CPallini 2,925


Advertise | Privacy | Mobile
Web03 | 2.6.130617.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid