none
How Can I Search Items With EmailMessageSchema.From RRS feed

  • Question

  • I want to search inbox with the From field.So I build the constrains with the code below:

            var fromConstrains = new SearchFilter.ContainsSubstring();
            fromConstrains.PropertyDefinition = EmailMessageSchema.Sender;
            
            fromConstrains.Value = model.From;
            andType.Add(fromConstrains);
    
    

    Then I use the "andType" to search my Inbox,because the from is just like 李晓强<lixiaoqiang@hotmail.com> so,the users input "李晓强" as the query condition, I sure have some email from 李晓强,but it did not search out any one....

    It just puzzled me...


    十步杀一人,千里不留行
    Monday, December 6, 2010 9:57 AM

All replies

  • If you just want to search the FromName then I would suggest you use the PR_Sender_Name Extended property http://msdn.microsoft.com/en-us/library/bb446050.aspx (equivilent to the urn:schemas:httpmail:fromname) instead eg
       ItemView iv = new ItemView(2000);
       ExtendedPropertyDefinition PR_SENDER_NAME = new ExtendedPropertyDefinition(3098, MapiPropertyType.String);
       SearchFilter sf = new SearchFilter.ContainsSubstring(PR_SENDER_NAME, "Text to search");
       FindItemsResults<Item> fiItems = service.FindItems(WellKnownFolderName.Inbox, sf, iv);
       foreach (Item itItem in fiItems.Items) {
        Console.WriteLine(itItem.Subject);
       
       }
    

    Cheers
    Glen

    Tuesday, December 7, 2010 2:14 AM
  • sorry,It seems not work! Still find nothing!


    十步杀一人,千里不留行
    Monday, December 13, 2010 5:23 AM
  • What version of Exchange are you using ? You said you using Anytype why what other properties are you querying on ? If your using 2010 then you could try an AQS query if you use canonical AQS query that should be reasonably language neutral

    FindItemsResults

     

     

    <Item> fiitems = service.FindItems(WellKnownFolderName.Inbox, "System.Message.FromName:\"Glen\"", iv);

    cheers
    Glen

    Tuesday, December 14, 2010 2:02 AM
  • Unless the search required is in Public Folders, which don't allow AQS.
    Thursday, October 4, 2012 9:31 PM