View Single Post
 
Old 09-24-2007, 03:55 AM
knut knut is offline
Novice
 
Join Date: Sep 2007
Posts: 1
knut
Default Redemption object and outlook

Hi All.

i have a problem with Redemption Objects .

i write a add in for outlook. this code must retrieve аll adresses from contact list.

i can get the Outlook OOM objects to work fine, but am having trouble
creating and using Redemption objects.
Here is my sample code to read a contact from the address book and
display the email address (bypassing the security prompt using
redemption):

what wrong?



Code:

void __stdcall CMyComAddIN::GetAdresses_Redemption()
{
    
    CoInitializeEx(NULL,COINIT_APARTMENTTHREADED);


    hr_pro_id = CLSIDFromProgID(L"Outlook.Application",&findCLSID);
    hr = olApp.CreateInstance(findCLSID);
    
    
    pFolder_ = olApp->GetNamespace(L"MAPI",&spNS);
    COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR); 
    HRESULT log = spNS->Logon(covOptional, covOptional, covOptional, covOptional);
    spNS->GetDefaultFolder(Outlook::olFolderContacts,&spContacts); 


    
    
     spContacts->get_Items(&spItms);
     spItms->GetFirst(&spFirstItem);


    CLSID clsid; 
    CComPtr<Redemption::ISafeContactItem> pSafeContactItem(NULL); 

     hr_form_prog_id =  CLSIDFromProgID(L"Redemption.SafeContactItem", &clsid);
     hr_ = pSafeContactItem.CoCreateInstance(clsid);

        
    BSTR emailAddress;
    pSafeContactItem->put_Item(pContact_); 
    pSafeContactItem->get_Email1Address(&emailAddress);
    

    
    while(spFirstItem)
    {
        pContact_ = spFirstItem;
        CComBSTR emailAddress;
        
        pSafeContactItem->get_Email1Address(&emailAddress);
        spFirstItem.Release();
        spItms->GetNext(&spFirstItem);
    }

    
     spNS->Logoff(); 
     CoUninitialize();

     
}
Reply With Quote