help! for currently selected Item?

D

Dkds.Naidu

Hi,

I am trying to get the currently selected item in the outlook folder.
I tried with the below code snippet. I got memory problems.
where is the problem?

void __stdcall COutlook::OnContextMenuUpdat()
{
CComQIPtr<Outlook::_Application> spApp(m_spApp);
CComPtr<Outlook::_Explorer> olExplorer;
olExplorer = spApp->ActiveExplorer();
CComPtr<Outlook::Selection> OLSelection;
olExplorer->get_Selection(&OLSelection);
if (OLSelection)
{
long count;
OLSelection->get_Count(&count);
LPDISPATCH lpDisp = NULL;
VARIANT var;
var.lVal = count;
lpDisp = OLSelection->Item(count);
if (lpDisp)
{
CComQIPtr<Outlook::_MailItem> mailItem(lpDisp);
BSTR bstr;
mailItem->get_Body(&bstr);//here I got memory problems. why?
}
}
}//end of function
DKDS.Naidu,
Programmer Analyst,
ITPL - Bangalore.
 

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