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

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

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 store 的 folder 。

** 得到最新添加的 ** ** pst store ** ** 的 ** ** folder **


_ 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. 先写到这里,想到了再补充

Published At
Categories with Web编程
Tagged with
comments powered by Disqus