Email SearchFilter on EmailMessageSchema.DisplayFrom RRS feed

  • Question

  • hello,

    I'm trying to include the From display name of an email in my search result when performing EWS search.  from the

    EmialMessageSchema has a property for DispalyTo and DisplayCC but I don't see DisplayFrom, does any one know why?

    and How I will be able to achieve search in email's from DispalyName?  I don't see a property DisplayBB.





    Tuesday, March 8, 2011 5:41 PM

All replies

  • You need to the Extended property

    PR_Sender_Name (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) {
    Wednesday, March 9, 2011 2:28 AM
  • Any chance of showing the code in the foreach that actually gets the From Name. I get a emails returned from the filter, but unable to get the from value.

    I have fooled with this and cannot get it go, and wondering if this is why it isn't in your example.<o:p></o:p>

    As a general question, any idea why they didn't just add the DisplayFrom value, seems sort of funny they wouldn't show this. Is there some secrete why they wouldn’t and make people go through these hoops to get a simple value?<o:p></o:p>

    Thanks for any input on this happy fun thing. <o:p></o:p>

    Richard Loba

    Tuesday, October 9, 2012 11:52 PM
  • Hello,

    Hello, I was able to get the FromName, from a guess, however, is there a wildcard that can be passed into the filter to get all emails?

    I’m trying to replace a SMTP Filter I wrote by having email sent to a regular mail box. Then I want to pick off email sent to it for processing.

    The wild card would be nice to just get the next email send to the system, but searching for actual names is a bit much.

    Thank you

    Richard Loba

    Wednesday, October 10, 2012 12:25 AM
  • Its sounds like what you need is the actual SMTP Address of the Sender ? If that's that case you need to make sure you call either load or LoadPropertiesfromItems as FindItems doesn't return the recipients, attachments or fromAddress. eg

                PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
                ItemView ivItemView = new ItemView(1000);
                FindItemsResults<Item> fiItems = null;
                do {
                    fiItems = service.FindItems(WellKnownFolderName.Inbox, ivItemView);
                    if (fiItems.Items.Count > 0) {
                        service.LoadPropertiesForItems(fiItems.Items, psPropSet);
                        foreach (Item itItem in fiItems.Items) {
                            if (itItem is EmailMessage) {
                    ivItemView.Offset += fiItems.Items.Count;
                while (fiItems.MoreAvailable == true);

    If you want every message in a folder then don't use a SearchFilter. That search does a substring search but wildcards aren't valid in any of the searchfilter. If your using Exchange 2010 then its better to use AQS for these type of searches see for more details.


    Wednesday, October 10, 2012 1:03 AM
  • Thanks Glen,

       Your suggestions will get me going in the direction I need to go. Yes, Attachments are also on the list of tasks, and your link will help me out greatly.

    Thanks again Glen


    Richard Loba

    Wednesday, October 10, 2012 2:01 AM