0
我正在嘗試編寫一個Office 2007 COM加載項,它將在發送郵件之前檢查一些規則。在測試代碼下面工作,但我在VS2010中有幾個警告,也許有人可以幫助我。下面COM加載項,Outlook,ItemSend
代碼:
Imports Extensibility
Imports System.Runtime.InteropServices
Imports Outlook = Microsoft.Office.Interop.Outlook
Imports Microsoft.Office.Core
Imports System.Reflection
Imports Microsoft.Win32
<GuidAttribute("B19F59E7-4F71-475C-9531-FB46842E5E5E"), ProgIdAttribute("DODATKI.Connect")> _
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim WithEvents OutlookApplication As Microsoft.Office.Interop.Outlook.Application
Private applicationObject As Object
Private addInInstance As Object
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
'MsgBox("Add-in is OnBeginShutdown")
End Sub
Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub
Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
MsgBox("Add-in is OnStartupComplete")
OutlookApplication = New Outlook.Application
End Sub
Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
End Sub
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
MsgBox("Add-in is OnConnection")
applicationObject = application
addInInstance = addInInst
' If you aren't in startup, manually call OnStartupComplete.
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _
Call OnStartupComplete(custom)
End Sub
Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles OutlookApplication.ItemSend
System.Windows.Forms.MessageBox.Show("Hi, You are sending message")
Dim Msg As Outlook.MailItem
Msg = Item
If Trim(Item.Subject) = "" Then
System.Windows.Forms.MessageBox.Show("Cannot send message with an empty subject!!!")
Cancel = True
End If
End Sub
End Class
警告:
1) On Msg = Item
Warning 1 Implicit conversion from 'Object' to Microsoft.Office.Interop.Outlook.MailItem'
2) On Item.Subject
Warning 2 Implicit conversion from 'Object' to 'String'
3) On Item.Subject
Warning 3 Late bound resolution; runtime errors could occur
謝謝,現在沒問題。也許你知道如何打開一個包含逗號的文件夾,其路徑如下: Shell(「explorer.exe \\ server \ path to,folder」,vbHide) 或 Shell(「cmd/c start \\ server \路徑,文件夾「,vbHide) – Marcin 2011-01-24 12:48:50