开发者

Com InvokeHelper Problem

开发者 https://www.devze.com 2023-03-03 10:57 出处:网络
I have found the following snippet of code on the internet, which creates an email from a template: LPDISPATCH _Application::CreateItemFromTemplate(LPCTSTR TemplatePath, const VARIANT& InFolder)

I have found the following snippet of code on the internet, which creates an email from a template:

LPDISPATCH _Application::CreateItemFromTemplate(LPCTSTR TemplatePath, const VARIANT& InFolder)
{
    LPDISPATCH result;
    static BYTE parms[] =
        VTS_BSTR VTS_VARIANT;
    InvokeHelper(0x10b, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, parms,
        TemplatePath, &InFolder);
    return result;
}

The problem that I have with this code is that it requires the last parameter to have a folder. With my code there is no folder, the email after it sent will be uploaded into another application. I have tried passing NULL as the last parameter, but this just throws an exception.

All I am trying to achieve is to open an email using a template with it visible on th开发者_运维知识库e user's Outlook Desktop. Therefore, my question is what should I pass as the parameters to this InvokeHelper method? Is it just the last parameter, or the last parameter be NULL, but the others changed, if so to what?

Thanks


try this code:

try 
{
    long rc = -1;
    static BYTE parms[] = VTS_BSTR VTS_BSTR VTS_BSTR VTS_BSTR VTS_BSTR VTS_I2;

    m_eventDispatchDriver.InvokeHelper(0x6003000c, DISPATCH_METHOD, VT_I4, (void*)&rc, parms,
                                       _UDATA(strSubject), 
                                       _UDATA(strBody), 
                                       _UDATA(strBody),
                                       _UDATA(strRecipients), 
                                       _UDATA(strAttachments),
                                       0 /*SendWithMailToIfOLDown*/);

    if (rc == 0)
        return RESULT_OK;
    else
        return RESULT_E_FAIL;
}
catch(COleDispatchException *pExeption)
{
    _UCHAR szError[256];
    pExeption->GetErrorMessage(szError, 256);
    LOG(failure: %s", _UADATA(strCommand), szError);
    return RESULT_E_FAIL;
}

where:

strSubject = ""

strAttachments = ""

strRecipients = "name@addr.com"

strBody = ""

after you get this to work, you can play with the parameters...

0

精彩评论

暂无评论...
验证码 换一张
取 消