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.