none
_propertyaccessor::setproperty() RRS feed

  • Question

  •        I worte a code followed:

    BSTR SetPro;
    SetPro=::SysAllocString(L"http://schemas.microsoft.com/mapi/proptag/0x3A701102");

    m_spApp->GetNamespace(bst,&spNamespace);  
    SysFreeString(bst);
    spNamespace->GetDefaultFolder(olFolderContacts,&spMAPIFold);
    spMAPIFold->get_Items(&spItems);

    spItems->Item(index,&pDisp);
    spContactItem=pDisp;

    spContactItem->get_PropertyAccessor(&spPa);
    VARIANT test=spSet.setpro();
    HRESULT hr=spPa->SetProperty(SetPro,test);

    spContactItem->Save();
    ::SysFreeString(SetPro);

    But I found the value of hr prompt Type mismatch. SetPro and test are all initialized according to declaration . who can help me ? I am using c++ and outlook2007

    • Moved by Cindy Meister MVP Saturday, November 10, 2012 7:24 AM not using VSTO technology (From:Visual Studio Tools for Office)
    Saturday, November 10, 2012 2:25 AM

Answers

  • You are returning a pointer to an integer.

    You need to provide a double array - variant array of variant arrays of bytes.

    Try to *read* a PT_MV_BINARY property to see what data you need to provide.


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

    Tuesday, November 13, 2012 1:36 PM
  • No, you are missing my point - I am telling you what Outlook *expects* to see.

    DISP_E_TYPEMISMATCH error is the manifestation of that.


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

    Tuesday, November 13, 2012 3:25 PM

All replies

  • What is the value spSet.setpro()?

    For the PT_MV_BINARY properyties (such 0x3A701102), the property value must a variant array. Each element of that array must be another variant array of byte.


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

    Saturday, November 10, 2012 6:29 PM
  •  It's data of certificate and it  has no error . My problem is which type is not match.

    The hr's value returned by SetProperty() is 0x80020005 . 

    the types of two parameters are in accordance with the requirements:

          virtual HRESULT __stdcall SetProperty (
            /*[in]*/ BSTR SchemaName,
            /*[in]*/ VARIANT Value ) = 0;

    The SetPro is the type of BSTR and test is the type of VARIANT. 

     
    Monday, November 12, 2012 3:21 PM
  • *What* exactly does that variant contain? You need to be a lot more specific than that.


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

    Monday, November 12, 2012 3:36 PM
  • The code of setpro() function followed:

    X509Certificate2^ x509=gcnew X509Certificate2("C:\\shiyan.cer");
    array<Byte>^rawdata=x509->RawData;

            int cer_len = rawdata->Length;
    int* cer_data;
    cer_data=new int[cer_len];

            IntPtr vPtr(cer_char);
    Marshal::Copy(rawdata,0,vPtr,cer_len);

           VARIANT test;

           test.vt=VT_BYREF|VT_INT;

           test.pintVal=cer_data;

          return test;

     
    Tuesday, November 13, 2012 12:41 PM
  • You are returning a pointer to an integer.

    You need to provide a double array - variant array of variant arrays of bytes.

    Try to *read* a PT_MV_BINARY property to see what data you need to provide.


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

    Tuesday, November 13, 2012 1:36 PM
  •     I know what data should be provided. My problem  is that the hr's value is not zero(HRESULT hr=spPa->SetProperty(SetPro,test);), but 0x80020005 ,

    Tuesday, November 13, 2012 3:03 PM
  • No, you are missing my point - I am telling you what Outlook *expects* to see.

    DISP_E_TYPEMISMATCH error is the manifestation of that.


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

    Tuesday, November 13, 2012 3:25 PM
  • oh.........   I see it and try it.

    thank you

    Wednesday, November 14, 2012 8:52 AM