Unable to use PropertyAccessor.SetProperty for "Total Work" property (Type Mismatch)

jamil haddadin 6 Reputation points
2021-03-05T18:41:17.873+00:00

This question is about VBA code that is trying to run on outlook M365 client on windows 10

I am trying to set the "Total Work" property for mailItem but it is always throwing "Type Mismatch" here is the code (olkTask is a mailItem object)
"Total Work" Property scheme is "http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81110003"

Set myPropSetting = olkTask.PropertyAccessor
 Dim x As Long
x = 2
 myPropSetting.SetProperty "http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81110003", x
                     olkTask.Save
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. jamil haddadin 6 Reputation points
    2021-03-07T22:15:40.613+00:00

    Thank you John, I have fixed the category

    0 comments No comments

  2. Viorel 112.5K Reputation points
    2021-03-08T08:42:49.94+00:00

    Did you try to read this property, and, if it returns some value, to determine its type? Maybe it is not Long.

    0 comments No comments

  3. jamil haddadin 6 Reputation points
    2021-03-08T09:48:22.893+00:00

    you are right! it is "Variant/Long", so when I changed it to Variant it works!

    Dim x As Variant
    x = 2
    If iTotalWork = 0 And iActualWork = 0 Then
    myPropSetting.SetProperty "http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81110003", x
    olkTask.Save
    End If

    0 comments No comments