ContactItem missing ItemProperties property

Add-in Express™ Support Service
That's what is more important than anything else

ContactItem missing ItemProperties property
 
Benoit Duchaine




Posts: 10
Joined: 2017-06-21
The ADX Outlook.ContactItem object does not include the ItemProperties of the real Outlook ContactItem object.

See : https://msdn.microsoft.com/VBA/Outlook-VBA/articles/contactitem-itemproperties-property-outlook

This is a dynamic method for me that I used in my code before using ADX. Is there another way for me to check if a ContactItem property/method/field exists or not?

I have Addin v7 (Standard)

Thank.
Posted 21 Jun, 2017 08:22:53 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Hello Benoit,

On that page you see members existing in Outlook 2016. In your code you see members existing in the Outlook version, an interop for which you are using.

Benoit Duchaine writes:
This is a dynamic method for me that I used in my code before using ADX. Is there another way for me to check if a ContactItem property/method/field exists or not?


Obviously, I miss something. What method? What Outlook version? What interop version are you using? Why would you need to check this?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 21 Jun, 2017 09:02:31 Top
Benoit Duchaine




Posts: 10
Joined: 2017-06-21
Sorry if I do not explain properly, here's an example of my old code without ADX (it is VB6 with Outlook 2007 library) :
Dim pContact As ContactItem, pProperty As String

' Code that finds a contact in a folder
Set pContact = nFolder.Items.Find("[Email1Address]= 'joe@doe.com'")

pProperty = "FirstName"
GetContactProperty = pContact.ItemProperties(pProperty) ' Would be equivalent as pContact.FirstName

The idea is to extract the contact property dynamically as they change with Outlook version.
Posted 21 Jun, 2017 09:44:38 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Then you need to switch to using interops for Office 2007. You can create a new project; this is a fastest way. Alternatively, you can remove Office-related interops from the References section of your project, copy required interops from {Add-in Express installation folder}\Redistributables\Interop Assemblies\{Office version} to {your project folder}\Interops, and then add these references to your project.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 21 Jun, 2017 09:51:11 Top
Benoit Duchaine




Posts: 10
Joined: 2017-06-21
Thanks for this option but it kind of defeats the purpose of having Add-In Express which was to avoid linking with specific Outlook Interop releases.
Posted 21 Jun, 2017 10:03:03 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Hello Benoit,

Every interop is built for a specific version of the corresponding type library.

If you need to support Office versions B, C, and D, you *should* use an interop for version B. If you need to support version A as well, you *should* use an interop for version A. *Should* is a roundabout way to say that you can use an interop of *any* Outlook version with your add-in. You may also write your add-in with no Outlook interop at all. Not using an interop means, you write your code using late binding. Using an interop allows writing *some* code in terms of early binding. Because every Outlook version introduces new features, choosing an interop is choosing between writing more or less code using late binding. I prefer to write less code using late binding. I assume you are like me.

Add-in Express provides an interop for version 2000 (version A); it is called version-neutral because you can use it with all Outlook versions. Since Outlook 2000 doesn't provide the ItemsProperty property (and object), you cannot use early binding to access that property in your project and you need to use late binding. But if you only need to support Outlook 2007 (version B) and higher, you can use an interop for Outlook 2007 so that your code is written using early binding.

You can find more details in my blog at https://www.add-in-express.com/creating-addins-blog/2010/03/16/interop-assemblies-late-binding/.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Jun, 2017 08:32:21 Top
Benoit Duchaine




Posts: 10
Joined: 2017-06-21
I agree with you, in order to do this, I added compile flags to check for specific minimum outlook version and avoid calling inexistant functions.

The idea behind using Addin Express was because my client did not want to call me everytime they upgraded to a new Outlook version. My old code (VB6) was working good from Outlook 2003 up to 2012 but 2016 introduced something more that prevented it from being installed and loaded in memory. So I am rewriting it in .NET, and decided to use your AddIn Express for future Outlook releases.

But it's all good, I already had an old unused function that did a big "Select Case" for each property of a Contact Item.

Thanks again, right now, everything works very well! :)
Posted 22 Jun, 2017 09:37:02 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
You are welcome!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Jun, 2017 10:07:30 Top