none
How to identify that - is user outside the organization ? - in Outlook 2010, using .NET code RRS feed

  • Question

  • In Outlook 2010, a message is shown for the receivers who do not belong to the organization.
    Can you please tell me which method is used for this task?

    I used AddressEntry.GetExchangeUser.PrimarySmtpAddress property to catch external users. This method searches user on exchange server and if not found, it throws exception (states him as external).

    But still for some users Outlook shows them out-of-organization and the macro code shows them as internal as they are present on exchange server.
    Can you please tell me the function/property used by the Outlook for it?


    • Edited by Dhananjay J. Talekar Friday, September 7, 2012 4:23 AM
    • Moved by Forrest GuoModerator Monday, September 10, 2012 1:42 AM VSTO (From:Developing Apps for Office)
    • Moved by Forrest GuoModerator Monday, September 10, 2012 1:54 AM Outlook forum is more appropriate (From:Visual Studio Tools for Office)
    Thursday, September 6, 2012 6:51 AM

All replies

  • hi Dhananjay,

    From the description above, I think the .NET code throws Exception unexpectedly. Normally we expect it returns Nothing(VB) if an address is not an exchange user, but no exception thrown. See interop API help: here.

    If possible please share the .NET code and Exception details here.

    thanks.


    Forrest Guo | MSDN Community Support | Feedback to manager

    Monday, September 10, 2012 2:03 AM
    Moderator
  • Have you looked at the AddressEntry.Type property? For the internal users, it will "EX". For the external users, "SMTP".

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

    Monday, September 10, 2012 3:46 AM
  • Hi Guo,

    Yes, it returns null value for "AddressEntry.GetExchangeUser" if the user isn't present on exchange.

    But, if you try to use property on the returned value like : 
    "AddressEntry.GetExchangeUser.PrimarySmtpAddress"
    it will no doubt throw exception- when the "GetExchangeUser" is null.


    From MSDN : Dhananjay J. Talekar

    Monday, September 10, 2012 5:55 AM
  • So return value of AddressEntry.GetExchangeUser() could tell if an address is in Exchange or external. When you want to call .PrimarySmtpAddress you should test return value of GetExchangeUser().

    thanks.


    Forrest Guo | MSDN Community Support | Feedback to manager

    Monday, September 10, 2012 6:14 AM
    Moderator
  • Hi,
    I am using it in the same way if you see the question.
    But the problem is, there are some business users which are present on our exchange - for them this method doesn't throws any exception, but Outlook correctly views them as External (Outlook 2010 : at top of mail being sent).

    Thats why i am curious to get the name of property/method used by Outlook for it.


    From MSDN : Dhananjay J. Talekar

    Monday, September 10, 2012 9:49 AM
  • Do you mean contacts in GAL? What is the value of the AddressEntry.Type property?

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

    Tuesday, September 11, 2012 2:26 AM
  • Hi Dmitry,

    Sorry for so late reply. This method too was not successful for catching those few users as external.

    It showed them as EX whereas Outlook2010 correctly showed them as external in GUI.


    From MSDN : Dhananjay J. Talekar

    Monday, September 17, 2012 5:39 AM
  • Try to check if the PR_EMS_AB_HOME_MDB property is present - it is only set for the GAL objects that have a mailbox:

    PR_EMS_AB_HOME_MDB = "http://schemas.microsoft.com/mapi/proptag/0x8006001F"
    Debug.Print AddressEntry.PropertyAccessor.GetProperty(PR_EMS_AB_HOME_MDB)


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

    Monday, September 17, 2012 6:24 AM
  • Hi Dmitry,
    When I used this property on receivers - I got following exception :
    The property "http://schemas.microsoft.com/mapi/proptag/0x8006001F" is unknown or cannot be found
    - for every internal as well as external user


    From MSDN : Dhananjay J. Talekar

    Tuesday, September 18, 2012 4:03 AM
  • Can you run the following script in Outlook VBA editor or OutlookSpy (click Script)?

    This worked for me in Outlook 2007, 2010 and 2013 as logn as the current user is an Exchange user.

    PR_EMS_AB_HOME_MDB = "http://schemas.microsoft.com/mapi/proptag/0x8006001F"
    set AE = Application.Session.CurrentUser.AddressEntry
    Debug.Print Ae.PropertyAccessor.GetProperty(PR_EMS_AB_HOME_MDB)


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

    Tuesday, September 18, 2012 4:26 AM
  • It too did not work, throwing same above "unknown property" exception ! :(

    Then I tested current session user as Ae.GetExchangeUser() - it says I am on exchange (as no exception).


    From MSDN : Dhananjay J. Talekar

    Tuesday, September 18, 2012 5:29 AM
  • Can you drill to a GAL contact in OutlookSpy (click IAddrBookj, "Open Root Container", etc.) and check if you can spot any differences between contacts and real EX users on the MAPI level?

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

    Tuesday, September 18, 2012 5:37 AM
  • Try http://www.dimastr.com/outspy


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

    Tuesday, September 18, 2012 6:52 AM