none
How can I call Exchange outlook CheckNames button event RRS feed

  • Question

  • Hi , All, 

    I  Creat outlook addin , when the email "To" textbox input Organization out user, I need the trigger my event .  like outlook CheckNames Button .  then My addin hide some element. 

    I use PropertyChange event,but not find To address 。

    mailItem.PropertyChange += mailItem_PropertyChange;

     void mailItem_PropertyChange(string Name)
            {
                if (Name == "To" || Name == "CC")
                {

        }

    }

    thanks.


    Anything is Possible!



    Thursday, March 12, 2015 8:22 AM

Answers

  • Hello Harvey,

    The PropertyChange event is not fired until a user switches the pointer to another field or an item is saved. The Outlook object model doesn't provide any specific events for that unfortunately.

    > How can I call Exchange outlook CheckNames button event

    1. Try to use the ResolveAll method of the Recipients class to attempt to resolve all the Recipient objects in the Recipients collection against the Address Book.

    2. The GetSelectNamesDialog method returns a SelectNamesDialog object for the current session. The SelectNamesDialog object supports displaying the Select Names dialog box for the user to select entries from one or more address lists in the current session.

    Sub ShowContactsInDialog() 
     Dim oDialog As SelectNamesDialog 
     Dim oAL As AddressList 
     Dim oContacts As Folder 
     
     Set oDialog = Application.Session.GetSelectNamesDialog 
     Set oContacts = _ 
     Application.Session.GetDefaultFolder(olFolderContacts) 
     
     'Look for the address list that corresponds with the Contacts folder 
     For Each oAL In Application.Session.AddressLists 
     If oAL.GetContactsFolder = oContacts Then 
     Exit For 
     End If 
     Next 
     With oDialog 
     'Initialize the dialog box with the address list representing the Contacts folder 
     .InitialAddressList = oAL 
     .ShowOnlyInitialAddressList = True 
     If .Display Then 
     'Recipients Resolved 
     'Access Recipients using oDialog.Recipients 
     End If 
     End With 
    End Sub


    Thursday, March 12, 2015 1:56 PM
  • Hi, Eugene Astafiev :

    Your answer is also let me know the other knowledge, thank you.

    I use the following code to solve my problem:

     void mailItem_PropertyChange(string Name)
            {
                if (Name == "To" || Name == "CC" || Name == "BCC")
                {
                    FillData();
                }
            }
    
    private void FillData()
            {
    public otherMailAddress = false;
                foreach (Recipient r in mailItem.Recipients)
                {
                    WriteLog("r.address:" + r.Address);
                    if (string.IsNullOrEmpty(r.Address)) continue;
                    if (r.Address.Contains(MAIL_OrganizationName) || r.Address.Contains(MAIL_OriginatingDomain))
                    {
                        //
                    }
                    else
                    {
                        otherMailAddress = true;
                        break;
                    }
                }
    
                if (mailItem.Recipients.Count>0)
                {
                   // todo something.
                }
            }



    Anything is Possible!

    Friday, March 13, 2015 6:39 AM

All replies

  • Hello Harvey,

    The PropertyChange event is not fired until a user switches the pointer to another field or an item is saved. The Outlook object model doesn't provide any specific events for that unfortunately.

    > How can I call Exchange outlook CheckNames button event

    1. Try to use the ResolveAll method of the Recipients class to attempt to resolve all the Recipient objects in the Recipients collection against the Address Book.

    2. The GetSelectNamesDialog method returns a SelectNamesDialog object for the current session. The SelectNamesDialog object supports displaying the Select Names dialog box for the user to select entries from one or more address lists in the current session.

    Sub ShowContactsInDialog() 
     Dim oDialog As SelectNamesDialog 
     Dim oAL As AddressList 
     Dim oContacts As Folder 
     
     Set oDialog = Application.Session.GetSelectNamesDialog 
     Set oContacts = _ 
     Application.Session.GetDefaultFolder(olFolderContacts) 
     
     'Look for the address list that corresponds with the Contacts folder 
     For Each oAL In Application.Session.AddressLists 
     If oAL.GetContactsFolder = oContacts Then 
     Exit For 
     End If 
     Next 
     With oDialog 
     'Initialize the dialog box with the address list representing the Contacts folder 
     .InitialAddressList = oAL 
     .ShowOnlyInitialAddressList = True 
     If .Display Then 
     'Recipients Resolved 
     'Access Recipients using oDialog.Recipients 
     End If 
     End With 
    End Sub


    Thursday, March 12, 2015 1:56 PM
  • Hi, Eugene Astafiev :

    Your answer is also let me know the other knowledge, thank you.

    I use the following code to solve my problem:

     void mailItem_PropertyChange(string Name)
            {
                if (Name == "To" || Name == "CC" || Name == "BCC")
                {
                    FillData();
                }
            }
    
    private void FillData()
            {
    public otherMailAddress = false;
                foreach (Recipient r in mailItem.Recipients)
                {
                    WriteLog("r.address:" + r.Address);
                    if (string.IsNullOrEmpty(r.Address)) continue;
                    if (r.Address.Contains(MAIL_OrganizationName) || r.Address.Contains(MAIL_OriginatingDomain))
                    {
                        //
                    }
                    else
                    {
                        otherMailAddress = true;
                        break;
                    }
                }
    
                if (mailItem.Recipients.Count>0)
                {
                   // todo something.
                }
            }



    Anything is Possible!

    Friday, March 13, 2015 6:39 AM