Outlook add-in plugin .Net development experience - Supplement (1)

zhaozj2021-02-16  44

Outlook add-in plugin .Net development experience - Supplement (1)

This time added something, expand the original text, in order to look at it, directly merge it.

For the first time, write this place, record the process in the development, .NET development settings are more complex in VB, to use the tool package provided by the Office in the VB, in order to use in the .NET development environment.

Development environment setting:

My development environment: Windows2k Professional Office XP

The object of all version of the Office is not the same, and the new version of the new version is also possible to discard the interface of certain objects. I have seen Office XP, office2000 Outlook objects, Outlook XP is more objects and interface functions than Outlook2000.

OfficeXP needs to configure the settings file provided by MS, which can be seen

(download).

Office 2003 is directly in the Office installation package, installs .NET development support, you can develop directly in VS.NET.

I use VB.NET development, which is more convenient to program the Outlook object (using withevents), if you use C #, you need to customize event parameters, set DELEGATE.

Secondary development for Outlook, cdo1.21 objects, this is not required, according to individual needs. With CDO1.21 objects, some of the more core Outlook methods can be used. These methods, attributes may not be available in the OUTLOOK object.

If you need more direct settings, get Outlook objects, you can control the API interface provided by Mapi32.dll, control, can maximize Outlook. These interfaces are most convenient to use C programming directly, I have no specification, I only tested some, and I don't say much.

Development process introduction:

In vs.net, other item à scalability item à shared add-in.

Choose a language:

Choose an external program to load the main program, I only select Outlook:

The program will help us automatically generate an Addin project, contain a connect.vb file, open a look.

Implements extensibility.idtextens Id interface.

In this way, we can get Outlook Application objects and manipulate Outlook.

Get Outlook Application object, manipulate Outlook

DIM M_OADDIN As Oladdin

Public Sub OnConnection (ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection

DIM OAPP as myoutlook.Application

Dim Otype As Type

Dim getProgid As Object

DIM MyProgid As String

DIM OARGS as Object ()

Try

m_oaddin = new oladdin

'Use invokemember to get progid of addininst object

Otype = addininst.gettypegetProgid = OTYPE.INVOKEMEMBER ("progid", _

Bindingflags.public or bindingflags.getfield or bindingflags.getproperty, _

Nothing, _

AddinInst, _

OARGS)

Myprogid = ctype (getProgid, String)

OAPP = ctype (application, myoutlook.Application)

'Don't call inithandler if Explorers.count = 0 and INSPECTORS.COUNT = 0

IF OAPP.Explorers.count = 0 and OAPP.Inspectors.count = 0 THEN

EXIT SUB

END IF

'Initialize Comaddin Object with this connect Object to allow

'External Clients To Get Access To Exposed Features

OAPP.COMADDINS.ITEM (MyProgid.tostring) .Object = ME

'Call INITHANDALER

m_oaddin.inithandler (OAPP, MyProgid)

Catch ex as systemexception

END TRY

End Sub

Of course, all the operations of Outlook can be processed in a separate class: m_oaddin.inithandler (OAPP, MyProgID)

转载请注明原文地址:https://www.9cbs.com/read-27291.html

New Post(0)