Query Interface on a C++ addin


J

James Callahan

I have built a C++ COM Addin for Outlook. All of the
reference material says I can access the Outllok Object
Model for Contacts as follows:

_ApplicationPtr pApp;
_ItemsPtr pItems;
MAPIFolderPtr pFolder;
_ContactItemPtr pContact;
hr=pApp.CreateInstance(__uuidof(Application));
pFolder = pApp->GetNamespace(_bstr_t("MAPI"))
->GetDefaultFolder(olFolderContacts);
pItems = pFolder->GetItems();
pContact = pItems->GetFirst();


Unfortunately, I get an error when I try to compile which
states that the GetNamespace does not take one parameter.
How can get to the interfaces in the mso.dll? I am using
the following import command:

#import "C\<my location>\mso.dll"
rename_namespace("Office"),named_guids
using namespace Office;
#import "C:\<my location>\MSOUTL.OLB"
rename_namespace("Outlook"), raw_interfaces_only,
named_guids
using namespace Outlook;

Thanks in advance,
James
 
Ad

Advertisements

M

Michael Tissington

Here is the list of imports that I use ...

#import "D:\My Documents\SQLView\Outlook\mso.dll"
#import "C:\Program Files\Common Files\Microsoft
Shared\VBA\VBA6\vbe6ext.olb"
#import "D:\My Documents\SQLView\Outlook\msoutl.olb"
rename_namespace("Outlook")
#import "C:\Windows\System32\stdole2.tlb" rename_namespace("Forms")
#import "C:\Windows\System32\fm20.dll" exclude("OLE_COLOR", "OLE_HANDLE",
"Font") rename_namespace("Forms")
 
G

Guest

Thanks for the list of imports but I am having some
diffculty with the "raw_interfaces_only" part. By
including that in the import statement, what am I
excluding?
Thanks
James
 
M

Michael Tissington

You should not use raw_interfaces_only.

Why don't you take a look at the generated header files to see the
difference.
 
Ad

Advertisements

J

James Callahan

Thanks...I printed the entire header file as well as the generated library
and see the difference. Only problem now is that if I remove the
"raw_intefaces_only" part, I generate a host of new errors in boilerplate
code from Amit Day's article on ALT/COM addins for Outlook. If I understand
correctly, we can access Office/Outlook type libraries by 1) using the
#import command, 2) including the generated midl files directly and 3) via
MFC COM. I have examples of two of the three and will experiment around to
see which works best. As it stands now, I am using the #import with the
raw_interfaces and have managed to access the functions I wanted although
not in the manner I expected. Is the "raw_intefaces_only" the reason that I
am forced to code
CComPtr <Outlook::_Namespace> bNamespace;
HRESULT hr = pApp->GetNamespace(_b_str_t("MAPI"), &bNamespace);
instead of
bNamespace = pApp->GetNamespace(_bstr_t("MAPI"));

I really appreaciate your taking the time with me. I am trying to expand my
horizons and learn this ALT/COM code.
James
 

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