none
Filter contact with Email1Address and Email2Address RRS feed

  • Question

  • Hi

    I need to filter my outlook contact according my condition. 

    Eg: I have 2 contacts

    ------------------------------------------------------------

    Contact1 Details :

    First Name : Bob

    Last Name : Paul

    Email1Address : Nil

    Email2Address : bob@example.com 

    Contact2 Details :

    First Name : Bob1

    Last Name : Paul1

    Email1Address : bob1@example.com

    Email2Address : bob2@example.com 

    -----------------------------------------------------------

    My Filter string is 

    1. [FIRSTNAME] = 'Bob' AND [LASTNAME] = 'Paul' AND [Email1Address] = '' AND [Email2Address] = 'bob@example.com'

    2. [FIRSTNAME] = 'Bob1' AND [LASTNAME] = 'Paul1' AND [Email1Address] = 'bob1@example.com' AND [Email2Address] = 'bob2@example.com'

    If i gave the filter to find()... i'm getting only the second contact... 

    Thanks

    Bobbin

    Monday, April 2, 2012 4:41 PM

Answers

All replies

  • If there is no e-mail address, the corresponding MAPI property will be NULL.

    Do not use

    [Email1Address] = ''


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!


    Monday, April 2, 2012 4:57 PM
  • Hi

    Actually first name, last name and email address will dynamically come from a table. my target is find the duplicate.

    I have a table. In that table there are so many contacts. I need to sync that contacts to Outlook contact. If the contact is already in the outlook contact no need to sync that contact to the outlook. contact is considering as

    outlookContact_firtname = TableContact_FirstName and outlookContact_lastname = TableContact_lastName and outlookContact_Email1Address = TableContact_Email1Address and outlookContact_Email2Address = TableContact_Email2Address

    First i will take all the contact using an Web service.

    Thanks

    Bobbin

    Tuesday, April 3, 2012 4:04 AM
  • if you need to match also by 'nulls' (so user John Novak and no email address is not the same as John Novak and some email address on the other side) then you need to use DASL names for email addresses to use 'IS NULL' condition. try using urn:schemas:contacts:email2 and urn:schemas:contacts:email3 for this.
    Tuesday, April 3, 2012 8:05 AM
  • Hi Damian

    Can you specify one example for filtering

    Thanks

    Tuesday, April 3, 2012 10:26 AM
  • Set its = ThisOutlookSession.Session.GetDefaultFolder(olFolderContacts).Items
    Set o = its.Find("@SQL=""http://schemas.microsoft.com/mapi/proptag/0x3A11001F"" = 'Novak' AND ""urn:schemas:contacts:email2"" IS NULL")
    Tuesday, April 3, 2012 10:38 AM
  • Hi I use simple mechanism (write as script in rule) to find and catalogue messages: Designation or transfer of unwanted e-mails (from Aliens)

    Take look on that, can be useful


    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved

    Tuesday, April 3, 2012 2:15 PM
  • Hi

    I tried you code like this, but its not working. Please correct me

    Outlook.Folder folder = SingleOutlookRef.Instance.OutlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;
                    int c = 0;
                    var AllConItems = folder.Items;
                    var FilterContactItems = AllConItems.Find(@"@SQL=http://schemas.microsoft.com/mapi/proptag/0x3A11001F = 'Test' AND urn:schemas:contacts:email1 IS NULL");
                    while (FilterContactItems != null)
                    {
                        if (FilterContactItems is Outlook.ContactItem)
                        {
                            Outlook.ContactItem fItems = (Outlook.ContactItem)FilterContactItems;
                            MessageBox.Show("Find : " + fItems.FirstName + " " + fItems.LastName + Environment.NewLine + "Email_1 :- " + fItems.Email1Address.ToString());
    
                            //fItems = (Outlook.ContactItem)this._smallOutlookItems.FindNext();
                        }
                        if (c == 100)
                        {
                            MessageBox.Show("inifinite Loop");
                            break;
                        }
    
                    }

     
    Tuesday, April 3, 2012 3:25 PM
  • you completly missed internal parentheses ("") for each DASL property name, look at my sample for @SQL and yours
    Tuesday, April 3, 2012 8:20 PM
  • Hi

    Con you explain what is this stands for  ""http://schemas.microsoft.com/mapi/proptag/0x3A11001F"" = 'Novak' . Mainly i need to know about "/proptag/0x3A11001F". What is this number "0x3A11001F"

    Thanks

    Bobbin

    Wednesday, April 4, 2012 2:30 AM
  • 0x3A11 is a mapi tag for PR_SURNAME and 001F means it is a unicode string. PR_GIVEN_NAME will have value of 0x3A06001F. Use OutlookSpy or MFCMAPI to see it yourself in your contact item.
    Wednesday, April 4, 2012 7:29 AM
  • See http://www.dimastr.com/redemption/utils.htm#xmapi for a simple explanation of how MAPI tags are constructed.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    Wednesday, April 4, 2012 11:45 PM