A
andy
Here is my scenario:
I have a java client and am developing a native Outlook add-in
component. I tried to use Redemption to bypass the Outlook security
warning and so far it works well (BTW, Redemption is a neat stuff).
However, when I tried to call _ISafeItem.SaveAs from native (C++) code
(I put my code snippet down below), it got an unexception exception:
Unexpected Signal : unknown exception code (0xeedfade) occurred at
PC=0x77E73887
Function=RaiseException+0x50
Library=E:\WINDOWS\system32\kernel32.dll
I also tried some standalone native code (using VB) to do the SaveAs.
no problem. So now I am really suspect the failure has something to do
with Java/native interop. Can that be something permission related? I
will appreciate any suggestion/comment. Thanks in advance.
-- Andy
P.S. my code snippet to call SaveAs to save the RFC raw data (which is
part of requirement).
/*************************************************/
JNIEXPORT jboolean JNICALL Java_Test_saveMailAsRFC822
(JNIEnv *env, jobject jobj, jstring filename, jstring messageID)
{
/*** I code a helper class so somehow I get the MailItem **/
// get ISafeMailItemPtr from MessageHelper
jboolean isCopy;
const wchar_t * nativeMailID = env->GetStringChars(messageID,
&isCopy);
OL::_MailItemPtr pMailItem =
helper->GetMailItemFromMap(_bstr_t(nativeMailID));
if (isCopy == JNI_TRUE)
{
env->ReleaseStringChars(messageID, nativeMailID);
}
const wchar_t * nativeFilename = env->GetStringChars(filename,
&isCopy);
// find Redemption class ID
CLSID clsid;
CLSIDFromProgID(L"Redemption.SafeMailItem", &clsid);
// Create instance of Redemption::SafeMailItem
Redemption::ISafeMailItemPtr pItem;
HRESULT hr = CoCreateInstance(clsid, NULL,
CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER,
__uuidof(Redemption::ISafeMailItem),
(void**)&pItem);
if(FAILED(hr))
{
printf("Redemption.dll is not registered. : Error!!");
return NULL;
}
pItem->AddRef();
pItem->Item = (IDispatch *)pMailItem;
/**** I tried some simple test here, just make sure the
MailItem pointer I got worked. And both statements executed fine ***/
printf((LPCSTR)pMailItem->Subject);
printf((LPCSTR)pItem->To);
/*** try to call SaveAs. However, exception happened here
****/
hr = pItem->SaveAs(_bstr_t(nativeFilename), Redemption:lRFC822);
if (isCopy == JNI_TRUE)
{
env->ReleaseStringChars(filename, nativeFilename);
}
/**** some other unrelated stuff ****/
}
I have a java client and am developing a native Outlook add-in
component. I tried to use Redemption to bypass the Outlook security
warning and so far it works well (BTW, Redemption is a neat stuff).
However, when I tried to call _ISafeItem.SaveAs from native (C++) code
(I put my code snippet down below), it got an unexception exception:
Unexpected Signal : unknown exception code (0xeedfade) occurred at
PC=0x77E73887
Function=RaiseException+0x50
Library=E:\WINDOWS\system32\kernel32.dll
I also tried some standalone native code (using VB) to do the SaveAs.
no problem. So now I am really suspect the failure has something to do
with Java/native interop. Can that be something permission related? I
will appreciate any suggestion/comment. Thanks in advance.
-- Andy
P.S. my code snippet to call SaveAs to save the RFC raw data (which is
part of requirement).
/*************************************************/
JNIEXPORT jboolean JNICALL Java_Test_saveMailAsRFC822
(JNIEnv *env, jobject jobj, jstring filename, jstring messageID)
{
/*** I code a helper class so somehow I get the MailItem **/
// get ISafeMailItemPtr from MessageHelper
jboolean isCopy;
const wchar_t * nativeMailID = env->GetStringChars(messageID,
&isCopy);
OL::_MailItemPtr pMailItem =
helper->GetMailItemFromMap(_bstr_t(nativeMailID));
if (isCopy == JNI_TRUE)
{
env->ReleaseStringChars(messageID, nativeMailID);
}
const wchar_t * nativeFilename = env->GetStringChars(filename,
&isCopy);
// find Redemption class ID
CLSID clsid;
CLSIDFromProgID(L"Redemption.SafeMailItem", &clsid);
// Create instance of Redemption::SafeMailItem
Redemption::ISafeMailItemPtr pItem;
HRESULT hr = CoCreateInstance(clsid, NULL,
CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER,
__uuidof(Redemption::ISafeMailItem),
(void**)&pItem);
if(FAILED(hr))
{
printf("Redemption.dll is not registered. : Error!!");
return NULL;
}
pItem->AddRef();
pItem->Item = (IDispatch *)pMailItem;
/**** I tried some simple test here, just make sure the
MailItem pointer I got worked. And both statements executed fine ***/
printf((LPCSTR)pMailItem->Subject);
printf((LPCSTR)pItem->To);
/*** try to call SaveAs. However, exception happened here
****/
hr = pItem->SaveAs(_bstr_t(nativeFilename), Redemption:lRFC822);
if (isCopy == JNI_TRUE)
{
env->ReleaseStringChars(filename, nativeFilename);
}
/**** some other unrelated stuff ****/
}