Outlook add-in plugin .Net development experience

zhaozj2021-02-16  54

Outlook add-in plugin .Net development experience

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).

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.

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.gettype

GetProgid = 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)

Some attention:

What should I do, I don't care, I look at MSDN.

I have some attention in the development process, column:

Processing in separate class OADDINs, join

1.

Public Class Outaddin

END CLASS

2. Clear Outlook objects:

Public Sub DisposeObject (Byval Obj As Object)

'Wraps ReleaseComObject to provide a' Safe 'Disposal Helper Method.

DIM Count As Integer

Try

IF obj is nothing then

EXITTY

END IF

IF not mathal.iscomobject (obj) THEN

EXITTY

END IF

Count = Marshal.ReleaseComobject (OBJ)

While count> 0

Count = Marshal.ReleaseComobject (OBJ)

End while

Catch ex as systemexception

Finally

Obj = Nothing

END TRY

End Sub

3. CDO1.21 Objects can be installed in the installation package of Office:

Set the folder's default post message attribute to custom Form

This property is looking for a long time, there is no mention in MSDN, stay here, I will not make Outlook development in the future.

g_olnamespace = m_oloutlookapp.Session

g_olnamespace.logon (, False, False)

g_objmapisession = new mapi.session

g_objmapisession.logon (, False, False)

Public Function SetFolderdftmsgpostClass (Byval Sstoreid As String) AS Booleandim ObjmapiFolder As Mapi.Folder

Dim objmapifields as mapi.fields

Const pr_def_post_displayname = & h36e6001e 'Custom Form's display name

Const pr_def_post_msgclass = & h36e5001e 'Custom Form's MessageClass name

Try

ObjmapiFolder = g_objmapisession.getFolder (SfolderID, SSTOREID)

Objmapifields = ObjmapiFolder.fields

Try

If Objmapifields.Item (pr_def_post_msgclass) .value = CVERSEMESSAGECLASS THEN

EXITTY

END IF

Catch exception

With objmapifields

.Add (pr_def_post_displayname, CVERSEFORMNAME)

.Add (pr_def_post_msgclass, cverseMessageClass)

End with

ObjmapiFolder.Update ()

END TRY

Catch exception

Finally

END TRY

DisposeObject (ObjmapiFields)

DisposeObject (ObjmapiFolder)

END FUNCTION

4. Other zero straws are also full, no longer rumor.

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

New Post(0)