Click here to Skip to main content
13,351,985 members (76,318 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 14 Dec 2002

Importing ActiveX Controls

, 14 Dec 2002
Rate this:
Please Sign up or sign in to vote.
This article is about importing a particular kind of COM component, a graphical one: the ActiveX control.
<!-- Download Links --> <!-- Add the rest of your HTML here -->

Importing ActiveX Controls

There are a lot of articles in net for using standard COM components in .NET applications. This article is about importing a particular kind of COM component, a graphical one: the ActiveX control. I’ve tried to import the MSMAPI ActiveX library. Before importing here is a brief introduction to ActiveX and MAPI.

What is an ActiveX control? An ActiveX control is really just another term for “OLE Object” or, more specifically “COM Object”. In another words, it supports IUnknown interface and is also self-registering. With the help of QueryInterface, a container can manage the lifetime of the control, as well as dynamically discover the full extent of a control’s functionality based on the available interfaces. This allows a control to implement as little functionality as it needs to.

MAPI is the Messaging Application Programming Interface, represents a comprehensive set of specifications that link messaging applications on the one hand and the service providers on the other, forming a messaging architecture. Although Microsoft is the prime supplier of MAPI components, it is by no means necessary to have a single Microsoft component to use MAPI (nor it is necessary to use a Windows or Win32 platform, actually). We can have a MAPI-complaint system with third party message store, address guide, and transport providers on a non-Windows operating system. MAPI is a part of WOSA, the Windows Open Services Architecture, which consists of common set of APIs for distributed computing. For more details, read MSDN.

Now, lets see how to import an ActiveX control. There are two ways to use ActiveX controls under .NET. We have an application called AxImp.exe, shipped with .NET SDK. This application does a similar kind of service for ActiveX controls that TlbImp.exe performs for non-graphical COM components. Basically, what it does is, it generates a wrapper component containing a type library that .NET can understand, and this wrapper component is capable of marshalling calls between the .NET runtime and the underlying COM object (the control). This application can from the command line, simply by passing the path and filename of the control.

This will create the file as <old_file.ocx> to <old_file.dll> and Ax<old_file.dll>. After creating the wrapper component add a reference to it and start using the control.

The other way is to import directly to the Visual Studio. We can add the controls to the toolbox by simply right clicking one of the tabs and selecting Customize Toolbox from the context menu. To do this select the COM Components tab and select or browse for the controls, you want to add. Here we want MAPI messages control and session control.

By doing this, we enable the Visual Studio, to create the wrapper component. After this we can use the wrapper component as proxy library, just like any other .NET component. Here is an example, to use this component to log on to MAPI session and send e-mail.

MAPISession objSession = new MAPISession();
MAPIMessages objMsg = new MAPIMessages();
objMsg.SessionID = objSession.SessionID;
objMsg.MsgSubject = "MAPI TEST";
objMsg.MsgNoteText = "The message body";
objMsg.RecipAddress = "<a href=""></a>";

That’s all.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Mercy Ponnupandy
United States United States
Architect / Consultant on Content Management and Cloud Computing... Artist and Author by the weekends...

You may also be interested in...


Comments and Discussions

QuestionSend a mail using default mail Client (Outlook). Pin
Member #205057820-Feb-07 1:38
memberMember #205057820-Feb-07 1:38 
AnswerRe: Send a mail using default mail Client (Outlook). Pin
Wizard1220-Feb-07 7:45
memberWizard1220-Feb-07 7:45 
GeneralActive X problem. Pin
abhi_638320-Jun-06 23:48
memberabhi_638320-Jun-06 23:48 
GeneralI don't have MAPI! Pin
jloiscan11-Apr-05 6:19
memberjloiscan11-Apr-05 6:19 
GeneralError using the app on a non development computer Pin
writeme15-Mar-04 17:40
memberwriteme15-Mar-04 17:40 
GeneralA couple suggestions Pin
Marc Clifton15-Dec-02 14:54
memberMarc Clifton15-Dec-02 14:54 
GeneralRe: A couple suggestions Pin
Wizard1215-Dec-02 18:41
memberWizard1215-Dec-02 18:41 
GeneralRe: A couple suggestions Pin
.S.Rod.16-Dec-02 2:08
member.S.Rod.16-Dec-02 2:08 
GeneralRe: A couple suggestions Pin
Anonymous8-Dec-03 12:32
sussAnonymous8-Dec-03 12:32 
GeneralRe: A couple suggestions Pin
John H Long22-Mar-05 10:09
memberJohn H Long22-Mar-05 10:09 
GeneralRe: A couple suggestions Pin
danilobq4-Jul-06 5:09
memberdanilobq4-Jul-06 5:09 
GeneralRe: A couple suggestions Pin
Marc Clifton4-Jul-06 5:56
protectorMarc Clifton4-Jul-06 5:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 15 Dec 2002
Article Copyright 2002 by Mercy Ponnupandy
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid