CSDN博客

img duibudui

Outlook add-in 插件.Net开发经验-补充(2)

发表于2004/1/5 12:02:00  990人阅读

分类: outlook

一些注意点:

       具体需要做些什么,个人需要,我也不仔细说了,察看msdn就明白了。

       我在开发过程中的一些注意,列一下:

1.       在单独类oAddin中处理,指定progID

指定progID

<GuidAttribute("CA940FE1-1193-411b-82DF-570A04491150"),

ProgIdAttribute("AddinForBible.olAddin")>

Public Class OutAddIn

End Class

 

2.       清除outlook的对象:

清除outlook的对象:

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

                    Exit Try

                End If

                If Not Marshal.IsComObject(obj) Then

                    Exit Try

                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对象在Office的安装包里可以安装,使用例子:

设置folder的default post message 属性为 自定义 form

这个属性找了很久,msdn里没有提及,留在这里吧,以后也不太会再作outlook开发了

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 '定制form的显示名字

            Const PR_DEF_POST_MSGCLASS = &H36E5001E  '定制form的MessageClass名称

            Try

                objMAPIFolder = g_objMAPISession.GetFolder(sFolderID, sStoreID)

                objMAPIFields = objMAPIFolder.Fields

                Try

                    If objMAPIFields.Item(PR_DEF_POST_MSGCLASS).value = cVerseMessageClass Then

                        Exit Try

                    End If

                Catch ex As Exception

                    With objMAPIFields

                        .Add(PR_DEF_POST_DISPLAYNAME, cVerseFormName)

                        .Add(PR_DEF_POST_MSGCLASS, cVerseMessageClass)

                    End With

                    objMAPIFolder.Update()

                End Try

            Catch ex As Exception

            Finally

            End Try

            DisposeObject(objMAPIFields)

            DisposeObject(objMAPIFolder)

End Function

 

 

4.         初始化outlook对象,取得基本的对象。

初始化outlook对象,取得基本的对象。

Imports myOutlook = Microsoft.Office.Interop.Outlook

 

Public g_olNamespace As myOutlook.NameSpace '当前outlook session对象

Public g_oBaseFolder As myOutlook.MAPIFolder '当前outlook folder对象

Public g_olApp As myOutlook.Application   '当前outlook对象

 

Public g_sStoreID As String

 

Private WithEvents m_olExplorer As myOutlook.ExplorerClass

'当前outlook explorer对象

 

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

 

 

取得folder对象:

namespace.folders.Item(“foldername”)

取得第一个名为foldernamefolder

namespace.GetFolderFromID(sFolderID,sStoreID)

取得指定IDfolder

FolderID , StoreID

Folder.EntryID

 

 

0 0

相关博文

我的热门文章

img
取 消
img