receiving email body and/or attachment data RRS feed

  • Question

  • hi,

    i'm writing a (com)plugin for tmail for devices supporting WM5+.

    i want the plugin to silently receive service data via email (for reasons beyond my control it *must* be sent via email) sent from a remote outlook server and activesync-ed onto the mobile device.

    since the size of data is likely to exceed the 2k/other limit policy that may have been imposed on the device; it may ordinarily get truncated.

    soooo, how do i programmatically do the equivalent of the user clicking on the *Get the rest of this message* (fetch email feature) link ?

    at this point i don't really mind whether my service data is contained either within an attachment or simply just in the message body (PR_BODY_A/PR_BODY_HTML_A).
    i also don't mind whether its acheivable only in unmanaged c++/com/brail/swahili etc.
    have scoured the net for a way forward ~returned with broken mast & torn sails.. grr
    any insight greatly appreciated..

    Monday, May 11, 2009 4:51 PM


  • so,

    for anyone thats curious, here's how i've made it happen (not in swahili)  :

    just call this from ur IMAPIAdviseSink::OnNotify implementation ~or wherever..
    NB: this only gets the MMS body content. if u want attachments, u need to use MSGSTATUS_REMOTE_DOWNLOAD_ATTACH

    HRESULT ommMAPIManager::GetServiceMessage()
        //logon to MAPI                                                       
        hr = MAPILogonEx(0, NULL, NULL, 0, &m_pSession);
        //open message using its entryID
        ULONG ulObjectType=     0;
        IMessage* pIMsg=        NULL;
        hr = m_pSession->OpenEntry(m_cbEntry, m_pstEntryID, NULL, MAPI_BEST_ACCESS, &ulObjectType, (LPUNKNOWN*)&pIMsg);    
        CBR(MAPI_MESSAGE == ulObjectType);
        //get the messages' current properties
        ULONG aulPropTags[] =           {1, PR_MSG_STATUS};
        ULONG ulPropCount=              0;
        SPropValue* pstCurrentProps=    NULL; //reference to an array of SPropValue types ~ in this case just one
        hr = pIMsg->GetProps((LPSPropTagArray)aulPropTags, MAPI_UNICODE, &ulPropCount, &pstCurrentProps);
        CBR(1 == ulPropCount);
        CBR(PR_MSG_STATUS == pstCurrentProps->ulPropTag);            
        //is there more of the msg to download
        BOOL bPartial=(pstCurrentProps->Value.ul & MSGSTATUS_PARTIAL) > 0;
        BOOL bRemoteDownload=(pstCurrentProps->Value.ul & MSGSTATUS_REMOTE_DOWNLOAD) > 0;
        //if there is then update the msg status property
        //by marking it for download
     (bPartial && !bRemoteDownload)
            SPropValue astNewProps[] = {0};
            astNewProps[0].Value.ul=pstCurrentProps->Value.ul | MSGSTATUS_REMOTE_DOWNLOAD;
            hr = pIMsg->SetProps(1, astNewProps, NULL);
     //can get the message body now

    have no idea if this is the best way or whether it leaks like crAzy, for now just happy that it works for me (WM5, ActiveSync etc)
    if anyone knows better pls advise =)


    • Marked as answer by violet313 Tuesday, May 12, 2009 5:39 PM
    • Edited by violet313 Tuesday, May 12, 2009 5:51 PM
    Tuesday, May 12, 2009 5:39 PM