Outlook Addin Reading Maill
-
Hi all, I am working on Outlook Addin using vc++. I am facing problem to the get_Subject or GetSubject method . Please give me the solution for this I have given the code snippet below.... Thanks In Advance..
// Variable Declaration CComQIPtrApplication; CComPtrpExplorer; CComPtrpSelection; CComQIPtrpMailItem; char *str=new char[100]; IDispatch *pDispatchItem; CComVariant covIndex; BSTR subject; pExplorer =Application->ActiveExplorer(); pSelection=pExplorer->GetSelection(); covIndex.vt = VT_I4 ; covIndex.lVal =1; pDispatchItem=pSelection->Item(covIndex); pMailItem=reinterpret_cast<_MailItem *>(pDispatchItem); **pExplorer->get_Subjet(&subject); // exception at this statement** str=_com_util::ConvertBSTRToString(subject);
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
-
Hi all, I am working on Outlook Addin using vc++. I am facing problem to the get_Subject or GetSubject method . Please give me the solution for this I have given the code snippet below.... Thanks In Advance..
// Variable Declaration CComQIPtrApplication; CComPtrpExplorer; CComPtrpSelection; CComQIPtrpMailItem; char *str=new char[100]; IDispatch *pDispatchItem; CComVariant covIndex; BSTR subject; pExplorer =Application->ActiveExplorer(); pSelection=pExplorer->GetSelection(); covIndex.vt = VT_I4 ; covIndex.lVal =1; pDispatchItem=pSelection->Item(covIndex); pMailItem=reinterpret_cast<_MailItem *>(pDispatchItem); **pExplorer->get_Subjet(&subject); // exception at this statement** str=_com_util::ConvertBSTRToString(subject);
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
Most probably the statement pExplorer =Application->ActiveExplorer(); has not succeeded . Try if(pExplorer) pExplorer->get_Subjet(&subject); // exception at this statement And if the if statement failes , then rewrite the allocation code as while(pExplorer!=NULL) { pExplorer =Application->ActiveExplorer(); } These problems arise mostly in plugin codes becasue , plugin try to use the default memory allocated for the application to which this plugin is intended (here outloook exe)
redindian
-
Most probably the statement pExplorer =Application->ActiveExplorer(); has not succeeded . Try if(pExplorer) pExplorer->get_Subjet(&subject); // exception at this statement And if the if statement failes , then rewrite the allocation code as while(pExplorer!=NULL) { pExplorer =Application->ActiveExplorer(); } These problems arise mostly in plugin codes becasue , plugin try to use the default memory allocated for the application to which this plugin is intended (here outloook exe)
redindian
Thanks For the reply.
dharani wrote:
f(pExplorer) pExplorer->get_Subjet(&subject); // exception at this statement
I am Very Sorry. I wrote the wrong statement in my question, the statement I intended to write is as follows... pMailItem->get_Subjet(&subject); But.... pExplorer->GetCaption(); this statment is giving the proper output.. Means there is no problem with pExplorer. Then what is the the problem with _MailItem even sometimes get_SenderName is giving the output. Please give me the solution. Thanks Again for ur Immidiate Reply and Helpful suggestion...
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
-
Hi all, I am working on Outlook Addin using vc++. I am facing problem to the get_Subject or GetSubject method . Please give me the solution for this I have given the code snippet below.... Thanks In Advance..
// Variable Declaration CComQIPtrApplication; CComPtrpExplorer; CComPtrpSelection; CComQIPtrpMailItem; char *str=new char[100]; IDispatch *pDispatchItem; CComVariant covIndex; BSTR subject; pExplorer =Application->ActiveExplorer(); pSelection=pExplorer->GetSelection(); covIndex.vt = VT_I4 ; covIndex.lVal =1; pDispatchItem=pSelection->Item(covIndex); pMailItem=reinterpret_cast<_MailItem *>(pDispatchItem); **pExplorer->get_Subjet(&subject); // exception at this statement** str=_com_util::ConvertBSTRToString(subject);
The secret of life is not enjoyment but education through experience. - Swami Vivekananda.
You will have to initialize the CComQIPtr Application pointer with the object from Outlook. What I can assume from your code is that you are not initializing this pointer with the outlook object. How does your application know that it has to get an instance for outlook, so this fails and then when you do something to get the subject it causes an exception to be thrown. you can also try debugging your application. Try something like this. I haven't checked the code but it might help you. CComQIPtr spApp; HRESULT hr = spApp.CoCreateInstance(__uuidof(Application)); if (FAILED(hr)){ MessageBox("Unable to instantiate Outlook.","Outlook Error",MB_OK); return 0; } -- modified at 0:30 Friday 10th November, 2006 Somethings seem HARD to do, until we know how to do them. _AnShUmAn_