I have a problem with an MFC Project that opens an email template, and sets some user properties on the mail item. The code I have been given with is as follows:
outlookmailitem->InvokeHelper(0xf816, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&userProps, NULL);
COleDispatchDriver* outlookUser = new COleDispatchDriver(userProps);
static BYTE params = VTS_BSTR VTS_I4 VTS_VARIANT VTS_VARIANT;
CString propertyName = _T("Email Marking");
outlookUser->InvokeHelper(0x66, DISPATCH_METHOD, VT_DISPATCH, (void*)&userProp1, params, propertyName, 1); //falls here!
COleDispatchDriver* outlookUserProp = new COleDispatchDriver(userProp1);
static BYTE params2 = VTS_VARIANT;
va1.vt = VT_BSTR;
va1.bstrVal = emailMarking.AllocSysString();
outlookUserProp->InvokeHelper(0x0, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, params2, &va1);
Where I have added "//falls here!" is where it fails, and I think this is parameter issue, again. I cannot tell you what the error message I am getting because all that VS2010 is giving me is unhandled exception.
Looking at MSDN for VBA - http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.userproperties.add.aspx#Y19 - it is final two parameters to me that Outlook is expecting, add to folders and display format. What I am trying to achieve is to ensure that the add to folder is set to false, and for the final one, I would like to set this to text if possible. How can set theses in MFC? What is the correct syntax? Do they need to set in this way or could Outlook set theses with the parameters being passed?