setting an IMAP accoutn as default from an addin

E

exchnerd

Hi

I need to set my IMAP4 account as the default store. Can anyone4 help me in
this regard?

Here is my code -

HRESULT hRes = S_OK;
IMsgServiceAdmin* pMsgAdmin = NULL;
IMAPITable* lppTable = NULL;
LPMAPIERROR* lppError = NULL;

try
{
if (FAILED(hRes = m_lpMAPISession->AdminServices(0,&pMsgAdmin)) )
{
Log(true,L"Error getting Admin service Table.");
return hRes;
}

if (FAILED(hRes = pMsgAdmin->GetMsgServiceTable(0, // Flags.
&lppTable))) // Pointer to table.
{
Log(true,L"Error getting Message Service Table.");
return hRes;
}

enum {iEntID,iSvcName, iSvcUID, cptaSvc};
SRestriction sres; // Restriction structure.
SPropValue SvcProps; // Property structure for restriction.

LPSRowSet lpSvcRows = NULL; // Rowset to hold results of table query.
//SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_ENTRYID,
PR_SERVICE_NAME, PR_SERVICE_UID,PR_DISPLAY_NAME_W};
SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_ENTRYID,
PR_SERVICE_NAME, PR_SERVICE_UID };
sres.rt = RES_CONTENT;
sres.res.resContent.ulFuzzyLevel = FL_SUBSTRING;
sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
sres.res.resContent.lpProp = &SvcProps;

SvcProps.ulPropTag = PR_SERVICE_NAME;
SvcProps.Value.lpszW = L"INTERSTOR";
//lppTable->FindRow()
if (FAILED(hRes = HrQueryAllRows(lppTable,
(LPSPropTagArray)&sptCols,
&sres,
NULL,
0,
&lpSvcRows)))
{
Log(true,L"Error querying table for new message Service ");
return hRes;
}

//LPMAPIUID lpMyServiceUID = (LPMAPIUID)lpSvcRows->aRow->lpProps
[iSvcUID].Value.bin.lpb;
LPENTRYID lpEntryID = (LPENTRYID)lpSvcRows->aRow->lpProps[iEntID].
Value.bin.lpb;
if (FAILED (hRes = m_lpMAPISession->SetDefaultStore
(MAPI_DEFAULT_STORE ,16,lpEntryID)) )
{
Log(true,L"Failed to SetDefaultStore %08x",hRes);
return hRes;
}


THe LPENTRYID seems to be invalid.
Thanks
 
E

Exchnerd

Hi

I need to set my IMAP4 account as the default store. Can anyone4 help me in
this regard?

Here is my code -

HRESULT hRes = S_OK;
    IMsgServiceAdmin* pMsgAdmin = NULL;
    IMAPITable* lppTable = NULL;
    LPMAPIERROR* lppError = NULL;

    try
    {
        if (FAILED(hRes = m_lpMAPISession->AdminServices(0,&pMsgAdmin)) )
        {
            Log(true,L"Error getting Admin service Table.");
            return hRes;
        }

        if (FAILED(hRes = pMsgAdmin->GetMsgServiceTable(0, // Flags.
            &lppTable))) // Pointer to table.
        {
            Log(true,L"Error getting Message Service Table.");
            return hRes;
        }

        enum {iEntID,iSvcName, iSvcUID, cptaSvc};
        SRestriction sres; // Restriction structure.
        SPropValue SvcProps; // Property structure for restriction.

        LPSRowSet lpSvcRows = NULL; // Rowset to hold results of table query.
        //SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_ENTRYID,
PR_SERVICE_NAME, PR_SERVICE_UID,PR_DISPLAY_NAME_W};
        SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_ENTRYID,
PR_SERVICE_NAME, PR_SERVICE_UID };
        sres.rt = RES_CONTENT;
        sres.res.resContent.ulFuzzyLevel = FL_SUBSTRING;
        sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
        sres.res.resContent.lpProp = &SvcProps;

        SvcProps.ulPropTag = PR_SERVICE_NAME;
        SvcProps.Value.lpszW = L"INTERSTOR";
        //lppTable->FindRow()
        if (FAILED(hRes = HrQueryAllRows(lppTable,
                                        (LPSPropTagArray)&sptCols,
                                        &sres,
                                        NULL,
                                        0,
                                        &lpSvcRows)))
        {
            Log(true,L"Error querying table for new message Service ");
            return hRes;
        }

        //LPMAPIUID lpMyServiceUID = (LPMAPIUID)lpSvcRows->aRow->lpProps
[iSvcUID].Value.bin.lpb;
        LPENTRYID lpEntryID = (LPENTRYID)lpSvcRows->aRow->lpProps[iEntID].
Value.bin.lpb;
        if (FAILED (hRes = m_lpMAPISession->SetDefaultStore
(MAPI_DEFAULT_STORE ,16,lpEntryID)) )
        {
            Log(true,L"Failed to SetDefaultStore %08x",hRes);
            return hRes;
        }

THe LPENTRYID seems to be invalid.
Thanks

Used the IOlkManager and IOlkAccount interfaces of outlook to get it
done!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top