Using VC to make a COM AddIn for Outlook -- what value does _NameSpace::Item want for the first argu

T

Ted Byers

Here is code I have in my COM class:

// _IDTExtensibility2
STDMETHOD(OnConnection)(IDispatch * Application, ext_ConnectMode
ConnectMode, IDispatch * AddInInst, SAFEARRAY * * custom)
{
appObj = (_Application*) Application;
_Application* appPTR = appObj;
_NameSpace* nsPTR;
BSTR s = SysAllocString(L"MAPI");
HRESULT rv = appPTR->GetNamespace(s,&nsPTR);
AddressLists* alsPTR;
nsPTR->get_AddressLists(&alsPTR);
AddressList* alPTR;
tagVARIANT ndx;
alsPTR->Item(ndx, &alPTR);


As you can see, I have used the ATL COM wizard to get a bunch of stuff set
up, and everything compiles down to the last shown line. But I have
searched the documents and the tlh file for Outlook, and I can not find
information on what Item wants for the first argument. Yes, I know it wants
a variant, but what value can I give it in order to get a single list
containing all the contact information Outlook has?

What makes this especially annoying is that it seems that all the Outlook
object model documentation seems to be using VB, and VB seems to use a very
different interface.

I NOW have another question, which may or may not make my first irrelevant.
On the diagram I have for the Outlook Object Model, ContactItem is not
shown. However, I find it in the index, and the page describing it makes it
appear that it is what I want to work with. I know I can create a new one
through _Application::CreateItem, but how do I get the ContactItem that has
just been either edited or deleted? Do I go through AddressLists to get
this information or through some other path?

Thanks,

Ted
 
D

Dmitry Streblechenko \(MVP\)

1. It takes either an integer index (1 through Count) or a string (name of
the address list)
2. Address entries and contact items are completely different beasts: it
just happens that Outlook Address Book exposes address entries created on
top of regular (IPM.Contact in this case) message. This is certainly not
true in caseof other address book providers, e.g. GAL.

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

Ted Byers

Thanks Dmitry

Somehow I am not surprised. What, then, is the way to get to the contact
items? I need to know this for two contexts: 1) where a change event has
occured, and I need to get the changed data, and 2) where I get revised data
for a contact and need to find the right contact item in order to
programmatically change the data Outlook has. The diagram I have of the
Outlook Object Model doesn't show ContactItem, and I know it exists only
because I saw entries for it in the contents.

Thanks,

Ted
 

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