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

zhaozj2021-02-16  47

Some attention:

What do you need to do, I don't carefully, I don't carefully, and I understand MSDN.

I have some attention in the development process, column:

1. Processing in separate class OADDIN, specifying Progid

PROGID

ProgidAttribute ("AddForbible.oladdin">

Public Class Outaddin

END CLASS

2. Clear Outlook objects:

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 Sfolderid AS String, Byval Sstoreid As String) AS Boolean

Dim 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. Initialize Outlook objects and obtain basic objects.

Initialize Outlook objects and obtain basic objects.

Imports myoutlook = Microsoft.Office.Interop.outlook

Public g_olnamespace as myoutlook.namespace 'Current Outlook Session object

Public g_obasefolder as myoutlook.mapifolder 'Current Outlook Folder object

Public g_olapp as myoutlook.Application 'Current Outlook object

Public G_SStoreid As String

Private WitHevents M_oleXplorer as myoutlook.explorerclass

'Current Outlook Explorer object

g_olnamespace = m_oloutlookapp.Session

g_olnamespace.logon (, False, False)

m_olexplorer = ctype (m_oloutlookapp.activeexplorer, myoutlook.explorerclass)

g_obasefolder = g_olnamespace.folders.item (FolderName)

g_sstoreid = g_obasefolder.storeid

Get the folder object:

Namespace.Folders.Item ("FolderName")

Get the first Folder named FolderName

Namespace.GetFolderFromid (Sfolderid, SstoreId)

Get the Folder of the specified ID

Folderid, StoreId

Folder.ENTRYID

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

New Post(0)