C++/VB - Exception in GetContentsTable
Asked By Victor
11-Nov-09 03:24 AM
Hello!
I have develop app to process messages from Outlook.
User select a folder in Outlook (using PickFolder method from Outlook OOM)
after that I convert it to IMAPIFolder to retrieve messages directly using
Extended MAPI. But I am getting an exception (Unhandled Exc at 0x000000c0 in
... : 0xC000005: Access violation reading location 0x000000C0)
Here is the code snippet of that:
pFolder=pApp->GetNamespace(_bstr_t("MAPI"))->PickFolder();
if (pFolder==NULL) return 0;
ATLASSERT(pFolder);
LPMAPIFOLDER pMapiFolder = NULL;
HRESULT hr = pFolder->get_MAPIOBJECT((IUnknown**)&pMapiFolder);
ATLASSERT(pMapiFolder);
LPMAPITABLE m_pContents;
pMapiFolder->GetContentsTable(CMAPIEx::cm_nMAPICode,&m_pContents); //
here I am getting an exception
(MAPI ogged on and intialized at another place. I
cutted it here)
Thank you.
Victor
OpenIMsgOnIStg
(1)
IMAPIFolder
(1)
CMAPIEx
(1)
Outlook
(1)
PFolder.GetPropertyByName
(1)
NMAPICode
(1)
GetContentsTable
(1)
VEntryID
(1)
Dmitry Streblechenko replied to Victor
You get back IUnknown from the MAPIOBJECT property .You need to QI it for
IMAPIFolder Extended MAPI interface first
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Victor replied to Dmitry Streblechenko
Thank you Dmitry for the answer!
I have figured it using pFolder.GetPropertyByName( L"EntryID", &vEntryID );
and then opened that folder through Ex MAPI using m_pMsgStore->OpenEntry(...)
Currently I am having another difficulty and your help will be very
appreciated.
When I read BodyFormat property of the message it returns 2 (html format).
BUT when I save it as MSG file it is saved as plain text. I want program to
retrieve body as plain text in that cases and not as HtmlBody.
How do I can differentiate it?
I think that message simply contained with both types (HTML and Plain text).
How do I can detect that message has both types then?
Thanks again, Dmitry!
victor
Dmitry Streblechenko replied to Victor
What do you see for PR_BODY / PR_HTML/ PR_RTF_COMPRESSED if you look at the
mesasge (click IMessage on the OUtlookSpy toolbar) and for teh MSG file
(click Misc | OpenIMsgOnIStg)?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Extracting Embedded images in Outlook 2007 C++ / VB In Outlook 2003 I had a macro to extract embedded images. This is it Sub SaveAttachment() Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set strFolderpath = CreateObject("WScript.Shell Nothing End Sub I do not know VB. However when I put this macro in Outlook 2007 I get this error message Can someone help me? Regards Doug VB COM Discussions Application.ActiveInspector.CurrentItem (1) Outlook 2007 (1) Outlook 2003 (1) Outlook.MailItem (1) WScript.Shell (1) VBA (1) VB (1) ObjAttachment.SaveAsFile (1
I am not, please let me know. I have a dilemma that starts with MS Outlook. I am trying to install updates onto the outlook Calendar without user intervention by using a vbScript. The problem that is happening is that if a user clicks on a button in Outlook called "Add Holidays . . ." then a GUI titled 'Add holidays to Calendar' is invoked. If I double click on a particular file in the program directory, namely Outlook.hol, then the GUI titled 'Add holidays to Calendar' is invoked. Another way of doing this is to navigate a DOS prompt to the folder where Outlook.HOL is located, type in Outlook.HOL and hit enter, then the GUI titled 'Add holidays to Calendar' is also invoked not know about? Thanks in advance, JeffH VBScript Discussions Scripting.FileSystemObject (1) WScript.CreateObject (1) Outlook (1) Office (1) ObjFSO.FileExists (1) ObjFSO.MoveFile (1) ObjFSO.CopyFile (1) Wscript.Shell (1 a parameter? Hi, The association on my machine is "C: \ PROGRA~1 \ MICROS~2 \ Office10 \ OUTLOOK.EXE" / hol "%1". When I try to pass this in as a parameter I receive
Outlook 2010 and the hierarchy table sort ordering. C++ / VB Our MAPI message store has three ordering, i.e. non-alphabetical. This used to work fine, but as of the latest Outlook 2010 beta we cannot get this to work. A short overview - Outlook does a IMAPITable.sortTable( PR_DISPLAY_NAME ) on the hierarchy table of our IPM_SUBTREE folder. - We return S_OK (if we return MAPI_E_TOO_COMPLEX or MAPI_E_NO_SUPPORT Outlook displays the according error to the user, and does not allow the tree to unfold) - Outlook 2000-2007 are now satistifed, and simply query our rows and displays the folders in the order our table provides them in. - However, Outlook 2010 displays the folders sorted by display name, ignoring the order our hierarchy table provides them in. As a sidenote, this behaviour only showed up in the recent beta, the Outlook 2010 technical preview had old-fashioned folder tree rendering, and did not show this new behaviour. Any thoughts on how we can force Outlook 2010 to respect our fixed sort order? And if this is not possible, any suggestions
Problem with IMAPITable returned from IMAPIFolder::GetContentsTabl C++ / VB This issue only happens in Outlook 2007, the code works fine in Outlook 2003. We have a folder created by a user under their Inbox. We get the IMAPIFolder interface via OpenEntry on the message store. I have confirmed the object type returned from that call is a folder (3). From the IMAPIFolder interface pointer, we call GetContentsTable(), which returns S_OK and fills up the IMAPITable pointer we an HRESULT of E_FAIL, which is very unusual. Any idea why this would work in Outlook 2003 and not in Outlook 2007? Win32 Messaging Discussions Outlook 2003 (1) Outlook 2007 (1) IMAPIFolder (1) IMAPITable (1) PbGlobalProfileSectionGuid (1) IProfSEct (1) ForMAPI (1
our custom message classes and would like to do specific tasks for those messages in Outlook. The task is like modifying few MAPI properties before sending the message. To get a MAPI IMessage object from currently selected mail, I am using the API get_MAPIOBJECT of Outlook::_MailItem interface. For this API, I am getting the error 0x80010105 (The server threw an properties propperly. We cannot use Exchange Client Extension interfaces, since Microsoft has deprecated them from Outlook 2010 onwards, so now dependant on OOM for handling UI events. Here is my code snippet: . . CComPtr<Outlook::Selection> olSel; hRes = m_spExplorer-> get_Selection(&olSel); if ( FAILED (hRes) ) return; long count; hRes = olSel-> get_Count count); if ( FAILED (hRes) ) return; LPDISPATCH olSelectedItem = NULL; CComQIPtr <Outlook::_MailItem> pMailItem; CComVariant covIndex; covIndex.vt = VT_I4; covIndex.lVal = 1; olSel-> Item(covIndex, &olSelectedItem); / / Get from Dmitry that the error 0x80010105 (RPC_E_SERVERFAULT) is something to do with the COM Server (Outlook.exe in our case). Dmitry could you please elaborate about the possible cause, I did custom message class. Please suggest if there is another approach to get MAPI object from Outlook UI? Thanks in advance! ~Aditya Gupta Win32 Messaging Discussions Outlook 2010 (1) Outlook (1) Error (1) MAPI properties (1) Exception (1) Class (1) Macro (1