Hi, I'm new around here, and specially around Redemption, but I quickly
got to realize it's a great tool. I only have one question (for now
-
I'm developing in Visual C++, and I'm trying to replace my old security
affected code, with the 'safe' code.
So, here is my old code:
//this is the code I want to replace:
CComPtr<Outlook::_NameSpace> spNS;
HRESULT hr = m_spApp->GetNamespace(T2W("MAPI"), &spNS);
CComPtr<Outlook::MAPIFolder> spContacts;
hr = spNS->GetDefaultFolder(olFolderContacts, &spContacts);
if(FAILED(hr))
return false;
CComPtr<Outlook::_Items> spItms;
hr = spContacts->get_Items(&spItms);
if(FAILED(hr))
return false;
CComPtr<IDispatch> spFirstItem;
hr = spItms->GetFirst(&spFirstItem);
if(FAILED(hr))
return false;
CString strTmp;
while(spFirstItem != NULL) //there are still addresses here
{
CComQIPtr<Outlook::_ContactItem> spFirstContactItem(spFirstItem);
//HOW DO I DO THIS IN THE CODE USING REDEMPTION???
BSTR emailAddress;
hr = spFirstContactItem->get_Email1Address(&emailAddress);
if(FAILED(hr))
return false;
strTmp = W2T(emailAddress);
if(!strTmp.IsEmpty())
m_saWhiteList.Add(strTmp);
spFirstItem.Release();
bFirstLoop = false;
hr = spItms->GetNext(&spFirstItem);
if(FAILED(hr))
break;
}
Now, I thought that I could use this instead:
...bla-bla
CComPtr<IDispatch> spFirstItem;
hr = spItms->GetFirst(&spFirstItem);
if(FAILED(hr))
return false;
ISafeContactItemPtr pSafeContact;
CLSID clsid;
if ((hr = ::CLSIDFromProgID(L"Redemption.SafeContactItem", &clsid)) !=
NOERROR)
{
return false;
}
if ((hr = ::CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
__uuidof(ISafeContactItem),
(void**)&pSafeContact)) != S_OK)
{
return false;
}
//HERE IS THE PROBLEM: How do I bound the info I have in spFirstItem, to
pSafeContact. In the old code, I only had to do this:
CComQIPtr<Outlook::_ContactItem> spFirstContactItem(spFirstItem);
CString strTmp;
if(pSafeContact != NULL)
{
BSTR emailAddress;
hr = pSafeContact->get_Email1Address(&emailAddress);
if(FAILED(hr))
return false;
strTmp = W2T(emailAddress);
bla-bla...
}
I hope I wasn't to complicated
Actually, all I want to know is how do
I bound spFirstItem to pSafeContact. Thank you!
Doru K.