Setting UserProperties -> DISP_E_TYPEMISMATCH

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

Setting UserProperties -> DISP_E_TYPEMISMATCH
 
BerndH




Posts: 50
Joined: 2014-09-23
Hi,
Ive tried the Code from Eugene
(https://www.add-in-express.com/creating-addins-blog/2011/08/19/how-to-add-a-custom-property-to-the-userproperties-collection-of-an-e-mail-item-in-outlook/)
It works fine at my computer. At the customer I got an exception (DISP_E_TYPEMISMATCH)
Do you have an idea, whats the problem? The only think I can imagine: I have Office 2016 and the client has Office 365. Is there a difference ?

Bernd
Posted 17 Aug, 2020 05:23:18 Top
Andrei Smolin


Add-in Express team


Posts: 17361
Joined: 2006-05-11
Hello Bernd,

What code line fails? In what event do you call that method?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 Aug, 2020 06:46:34 Top
BerndH




Posts: 50
Joined: 2014-09-23
Exception is in line:
mailUserProperty = mailUserProperties.Add("TestUserProperty", Outlook.OlUserPropertyType.olText, false, 1);

I have a method which creates a new mail and send them to a user (if he presses a button on a special form in my outlook) I create a new mail item, set subject, recipient, attachments and then I call the routines of your example.
On my computers it works fine ... so the code is okay I guess ;-) (I tried debug and release)

And if I look into the headers of the sended mail the properties are set.

Only on the customers computer ... exception...
Posted 17 Aug, 2020 07:02:57 Top
Andrei Smolin


Add-in Express team


Posts: 17361
Joined: 2006-05-11
Hello Bernd,

BerndH writes:
mailUserProperty = mailUserProperties.Add("TestUserProperty", Outlook.OlUserPropertyType.olText, false, 1);


1 stands for what enum value?

What store type the customer is using? Can you reproduce the issue on that store type?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Aug, 2020 11:17:17 Top
BerndH




Posts: 50
Joined: 2014-09-23
Your example says 1 is OlFormatText (introduced in Outlook 2007)...

so as Im the "master of try and error" .. with these changes I got it working:

mailUserProperties = mail.UserProperties;
mailUserProperty = mailUserProperties.Add(propertytext,Outlook.OlUserPropertyType.olText);
mail.UserProperties[propertytext].Value = propertyvalue;
mail.Save();


So .. problem solved ;-)
Posted 18 Aug, 2020 12:52:29 Top
Andrei Smolin


Add-in Express team


Posts: 17361
Joined: 2006-05-11
Great! Just great!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Aug, 2020 04:31:38 Top