Pb: retrieving empty subject from Item in Inspector

D

DarkJem

Hi,

I'm trying to retrieve the parts of a newly created mail.
I add a button on the new Inspector which is shown when clicking on
the New Message button.
WHen I clik on this button I have the following function :

void __stdcall CAddin::NewMail(IDispatch * Ctrl, VARIANT_BOOL *
CancelDefault)
{
USES_CONVERSION;
// Retrieving the button
Office::_CommandBarButtonPtr pCommandBarButton(Ctrl);

// Retrieving the inspector
Outlook::_InspectorPtr inspecteur;
HRESULT hr = m_spApp->ActiveInspector(&inspecteur);
if (FAILED(hr))
return;
else {
IDispatch* objetCourant;
// retrieve the current item
inspecteur->get_CurrentItem(&objetCourant);

Outlook::_MailItemPtr mailItem;
hr = objetCourant->QueryInterface(Outlook::IID__MailItem,(void**)&mailItem);
if (FAILED(hr))
return;
}
else {
BSTR subject;
mailItem->get_Subject(&subject);
MessageBoxW(GetForegroundWindow(),subject,L"Subject",MB_OK);
}
}
inspecteur->Close(olDiscard);
pCommandBarButton->Release();
}


Everything is working fine except that the MessageBox is empty. I add
a subject to my message but it is not retrieved by the get_Subject()
method. It is the same for each property that I try to get.

Do I have to refresh my inspector ? If yes how can I do?
Am I on the right way to achieve my goal?
Do I miss something?
How can I get the mail subject (and body, attachments and so on...)
from the Inspector of the new message?

Please help!!! ;-)

Thanks in advance.
Best Regards

Jeremie Moenne-Loccoz
 

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