0
メールが送信される前にいくつかのルールをチェックするOffice 2007 COMアドインを作成しようとしています。テストコードの下で動作しますが、私はVS2010でいくつかの警告があり、誰かがこれを手伝ってくれるかもしれません。以下COM ADD-in、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
のようなものを追加し、それは今okです、ありがとうございました。 ( "cmd.exe/c start \\ server \ path"、 "folder"、vbHide) シェル( "explorer.exe \\ server \ path"パス、フォルダ "、vbHide) – Marcin
こんにちはMarcin。それがあなたの質問に答えるなら、あなたは私の答えを「受け入れた」と考えるかもしれません。また、新しい質問としてあなたのさらなるコメントを再定式化したいかもしれません - 答えを得るより良いチャンス。 –