typemismatch by reading user property

  • Thread starter Thread starter Hahn, Thomas
  • Start date Start date
H

Hahn, Thomas

Hallo NG,

I have an VB.NET application that open an email and read some user
properties. By reading one of the user property I get the exception
"HERSULT:0x80020005 (DISP_E-TYPEMISMATCH)". In my developer and test area
(that is an vm-system) my application works realy fine. All my user
properties will reading by my application. Both systems are the same
configuration (Win2003 server with sp2 and .Net framework 2)

Can anyone explain me the error message?

many thanks ,
Thomas
 
Hard to tell from that exception other than the obvious, that there was a
type mismatch in the call.

Does that UserProperty actually exist in the item being read on that target
system?
 
The property is reading by a function.
The inputparameter for the function is the name of the user property.

------- my function -------------

Private Function CheckOLUserProp(ByVal tUserPropName As String, ByVal
fReturnException As Boolean) As Outlook.UserProperty
Try
If mhMailItem.UserProperties.Find(tUserPropName) IsNot Nothing Then
Return mhMailItem.UserProperties.Find(tUserPropName)
Else
If fReturnException Then Throw New Exception
End If

Catch ex As Exception
If fReturnException Then
Throw New Exception("Feld '" & tUserPropName & "' konnte in Mail
nicht ermittelt werden")
Else
Return Nothing
End If
End Try
End Function
 
Which line is firing the exception?

Does it work any better if you supply True for the optional Custom argument
to UserProperties.Find()?
 
The exception is fired by trying to find my property

If mhMailItem.UserProperties.Find(tUserPropName) IsNot Nothing Then

Sorry
what do you mean with "true for the optional Custom argument to
UserProperties.Find()"?

Thomas
 
If mhMailItem.UserProperties.Find(tUserPropName, True) IsNot Nothing
Then

That's what I meant by the optional Custom property. It's listed in the
Object Browser for UserProperties.Find().

I'd also start by verifying each object instead of using dot operators there
to help localize the problem. For example instead of:

If mhMailItem.UserProperties.Find(tUserPropName, True) IsNot Nothing
Then

use something like this:

If (mhMailItem IsNot Nothing) Then
Dim colProps As Outlook.UserProperties = mhMailItem
If (colProps IsNot Nothing) Then
' now use colProps with the Find method

That way you can tell where things are failing exactly.
 
I have changed my application, but the error is already exist.

I test the mailitem with a old testprogramm (create in vb 6). It show me
some information about the selected mailobject. If I checked the mailobject
on my client I get the value 'WAHR' for the userproperty. On the server I
get for the same property the value 'true'

Both systems have german as system language, but on the server I get an
TRUE. WHY?
Is that the reason of my error?

Thomas
 
Is this a string property or a boolean property? Normally for a boolean you
are checking the value for true or false and that's language independent (or
should be).

You should check to see exactly how you are retrieving the property value in
both versions and see if perhaps you are using a .ToString() somewhere or
something like that which is testing for a string value rather than the int
based boolean true or false.

At worst you could just check for both "true" and "wahr".
 
Hi Ken,

This command 'UserProperties.Find' fired the error! If I checked the
userproperties in a for loop I find the property and can read them.

Why the Find method fired an error - I don't no! Do you know it?

Thanks for your help

Thomas
 
That is weird and I've never seen that.

Do you get the same error if you use slightly different syntax for finding a
UserProperty, such as this, do you still get an error:

If mhMailItem.UserProperties.Item(tUserPropName) IsNot Nothing Then
 
Back
Top