CreateItem change for Outlook 2007? E_NOINTERFACE for returned objects.

M

msoliver

I'm writing a simple C++/ATL program that is interacting w/ the
Outlook object model. There seems to be some odd change to
Application.CreateItem for Outlook 2007. Here are my simple lines of
code:

Outlook::_ApplicationPtr spApplication;
Outlook::_MailItemPtr spMailItem;

HRESULT hr =
spApplication.CreateInstance(__uuidof(Outlook::Application));
if (FAILED(hr))
return;
spMailItem = spApplication->CreateItem(Outlook::eek:lMailItem);

spMailItem is NULL after this code executes. Stepping into CreateItem,
I see that it is returning a IDispatch*, but then when the
QueryInterface occurs for the _MailItem* interface, the COM error code
is: E_NOINTERFACE.

This seems to be the case for all of the different types of Outlook
items, not just mail items.

What changed? What object is being returned by CreateItem? I've looked
all over the net and MSDN and found no info - am stumped.
 
D

Dmitry Streblechenko

I don't think anything changed in that area. Does it make any difference if
Outlook is already running when your code is executed?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

msoliver

I don't think anything changed in that area. Does it make any difference if
Outlook is already running when your code is executed?

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

No diffference. Same result if Outlook is running. CreateItem is
returning an IDispatch object, just can't seem to QueryInterface on it
to get the right item... Any ideas?

Thx,

- Mike
 
D

Dmitry Streblechenko

Can you check that the GUID is right?? Or hardcode QI to use
{00063034-0000-0000-C000-000000000046}?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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