D
DarkJem
Hi,
I'm trying to write my Add-In for Outlook in C++/ATL and I encounter
some problems when trying to access the subject of a _MailItem.
Here is my code in addin.cpp
void __stdcall CAddin::OnSelectionChange()
{
// Retrieving the current folder
CComPtr<Outlook::MAPIFolder> curFolder;
// spExplorer is a global variable where I store the Explorer object
spExplorer->get_CurrentFolder(&curFolder);
// retrieving the current selection
CComPtr<Outlook::Selection> mySelection;
HRESULT hr = spExplorer->get_Selection(&mySelection);
if ( FAILED( hr ) ) return;
long count = 0;
hr = mySelection->get_Count(&count);
if ( FAILED( hr ) ) return;
// loop through the selected mails.
for ( int i = 1; i <= count; ++i )
{
CComVariant index( i );
// get the selected mail
CComPtr<Outlook::_MailItem> spItem;
hr = mySelection->Item( index, (IDispatch**) &spItem ); if (
FAILED( hr ) ) return;
// Check if item really is an email object.
OlObjectClass cls;
hr = spItem->get_Class( &cls );
if ( FAILED( hr ) ) return;
if ( cls == Outlook:lMail )
{
CComBSTR spSubject;
HRESULT hr = spItem->get_Subject(&spSubject);
// Here I get the following error message :
// Run-Time Check Failure #0 - The value of
ESP was not properly saved across a function call. This is usually a
result of calling a function declared with one calling convention with
a function pointer declared with a different calling convention
if ( FAILED( hr ) ) return;
// do some stuff with the mail
}
}
}
I really don't know how to overcome this issue. I did'nt find any work
around for this specific problem anywhere.
I'm not very familiar with outlook programming so any help would be
very welcome!!
Thanks
Regards
Jeremie
I'm trying to write my Add-In for Outlook in C++/ATL and I encounter
some problems when trying to access the subject of a _MailItem.
Here is my code in addin.cpp
void __stdcall CAddin::OnSelectionChange()
{
// Retrieving the current folder
CComPtr<Outlook::MAPIFolder> curFolder;
// spExplorer is a global variable where I store the Explorer object
spExplorer->get_CurrentFolder(&curFolder);
// retrieving the current selection
CComPtr<Outlook::Selection> mySelection;
HRESULT hr = spExplorer->get_Selection(&mySelection);
if ( FAILED( hr ) ) return;
long count = 0;
hr = mySelection->get_Count(&count);
if ( FAILED( hr ) ) return;
// loop through the selected mails.
for ( int i = 1; i <= count; ++i )
{
CComVariant index( i );
// get the selected mail
CComPtr<Outlook::_MailItem> spItem;
hr = mySelection->Item( index, (IDispatch**) &spItem ); if (
FAILED( hr ) ) return;
// Check if item really is an email object.
OlObjectClass cls;
hr = spItem->get_Class( &cls );
if ( FAILED( hr ) ) return;
if ( cls == Outlook:lMail )
{
CComBSTR spSubject;
HRESULT hr = spItem->get_Subject(&spSubject);
// Here I get the following error message :
// Run-Time Check Failure #0 - The value of
ESP was not properly saved across a function call. This is usually a
result of calling a function declared with one calling convention with
a function pointer declared with a different calling convention
if ( FAILED( hr ) ) return;
// do some stuff with the mail
}
}
}
I really don't know how to overcome this issue. I did'nt find any work
around for this specific problem anywhere.
I'm not very familiar with outlook programming so any help would be
very welcome!!
Thanks
Regards
Jeremie