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

类别:.NET开发 点击:0 评论:0 推荐:

这里上传文件字数太少,只能分多次。

1.         outlook里创建Menu, Button

outlook里创建Menu, Button

Private m_oMainMenu As Office.CommandBarPopup

Private WithEvents mnuLogInOff As Office.CommandBarButton

 

Dim oBars As Office.CommandBars

Dim oMenuBar As Office.CommandBar

 

'添加及选择工具栏

oBars = m_olExplorer.CommandBars     '取所有菜单栏

oMenuBar = oBars.ActiveMenuBar    '取当前菜单栏

 

'添加主菜单

m_oMainMenu = CType(oMenuBar.Controls.Add(10, , , ,True),Office.CommandBarPopup)

m_oMainMenu.Caption = "MainMenu"

 

'添加菜单项

mnuLogInOff = CType(m_oMainMenu.Controls.Add(Type:=1), Office.CommandBarButton)      ', Temporary:=True, Before:=1)

mnuLogInOff.Caption = " mnuLogInOff"

mnuLogInOff.Enabled = True

 

2.         创建,修改Folder view

创建,修改Folder view

Folder view xml格式。

Dim myView As myOutlook.View

Dim myViews As myOutlook.Views

 

myViews = g_oBaseFolder.Views

myView = myViews.Add(Name:="Normal View", _                                   ViewType:=myOutlook.OlViewType.olTableView, SaveOption:=myOutlook.OlViewSaveOption.olViewSaveOptionAllFoldersOfType)

myView.XML = sViewXML

myView.Save()

 

3.         修改类别 category

category信息,存放在注册表内。

'**********************************

'增加,修改category,调试

'**********************************

Private Sub mnuDebug2_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles mnuDebug2.Click

 

            Dim sSubkey As String

            Dim sValueName As String

            Dim oValue As Object

 

            sSubkey = "Software\Microsoft\Office\10.0\Outlook\Categories"

            sValueName = "MasterList"

            oValue = GetRegisterValue(sSubkey, sValueName, modOutlook.RegTypeEnum.RegBinaryType)

 

            Dim sOldCategories As String

            sOldCategories = GetRegisterValue(sSubkey, sValueName, modOutlook.RegTypeEnum.RegBinaryType)

 

            Dim sNewCategories As String

            sNewCategories = InputBox("Please input new categories,use;split", "Input", sOldCategories)

            ' sNewCategories = "custom;VIP;策略;等待;电话;个人;供应商;观点;国际;贺卡;假日;竞争;礼物;目标/目的;商务;时间和经费;收藏夹;熟人;杂项"

            sNewCategories = Trim(sNewCategories)

            If Right(sNewCategories, 1) = ";" Then

                sNewCategories = Trim(Left(sNewCategories, sNewCategories.Length - 1))

            End If

            oValue = EncodeChineseString2Unicode(sNewCategories)

            SetRegisterValue(sSubkey, sValueName, oValue)

 

            MsgBox(sNewCategories, MsgBoxStyle.Information)

 

        End Sub

Category在注册表里是byte[]保存

 

4.         得到最新添加的pst storefolder

得到最新添加的pst storefolder

m_olNamespace.AddStore(sStorePath)

oPstFolder = m_olNamespace.Folders.GetLast

m_sStoreID = oPstFolder.StoreID

DebugWriter("StoreID: ", m_sStoreID)

 

#Region "调试所用的函数,可以调试输出,或出文件"

     Public Sub DebugWriter(ByVal strSource As String, Optional ByVal strMessage As String = "")

 #If constDebug Then

            Dim tempPath As String = Path.GetTempPath()

         'Dim tempPath As String = "C:\"           

Dim myFile As New StreamWriter(tempPath & "debug.txt", True)

            Try

                Dim strError As String = Now().ToString & Chr(9) & strSource & Chr(9) & strMessage

                myFile.WriteLine(strError)

            Finally

                myFile.Close()

            End Try

#Else

            Debug.WriteLine(strSource & Chr(9) & strMessage)

#End If

        End Sub

#End Region

 

5.         做某些操作会出现outlook得安全警告,例如:发送邮件,查询address ……

看看这些:

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q290/4/99.asp&NoWebContent=1

http://www.microsoft.com/china/msdn/library/dnout2k2/html/odc_olsecurityovw.asp#odc_olsecurityovw_topic7

 

6.         先写到这里,想到了再补充

 

本文地址:http://com.8s8s.com/it/it45191.htm