0
Outlook程序我在VS2010寫了這個小程序在Outlook 2007中以附件移動到子文件夾
它的工作原理,通過收件箱中的閱讀標準運行,但我不能讓它正確指向其他文件夾,我得到一個「COMException被用戶代碼未處理」錯誤,說「操作失敗,找不到對象」。 ...
我已經包括了我的Outlook結構的截圖,如果它可以幫助...
Imports Microsoft.Office.Interop
Public Class ThisAddIn
Private Sub ThisAddIn_Startup() Handles Me.Startup
End Sub
Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
End Sub
Private Sub Application_Startup() Handles Application.Startup
Dim MyApp As Outlook.Application = New Outlook.Application
Dim MyNS As Outlook.NameSpace = MyApp.GetNamespace("MAPI")
Dim MyInbox As Outlook.MAPIFolder = MyNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim MyEmails As Integer = MyInbox.Items.Count
Dim MyEMail As Outlook.MailItem
Dim MyCount As Integer
Dim MySubFolder As Outlook.MAPIFolder = MyNS.Folders("Kickabout") **<<< Error occurs here**
For MyCount = MyEmails To 1 Step -1
MyEMail = MyInbox.Items(MyCount)
If MyEMail.SenderEmailAddress = "[email protected]" Then
If MyEMail.Attachments.Count > 0 Then
MySubFolder = MyNS.Folders("Kickabout\Attachments")
End If
MyEMail.Move(MySubFolder)
End If
Next
End Sub
End Class
您是否嘗試過使用調試器和SETT在'Dim MySubFolder ...'行添加一個斷點並展開'MyNs.Folders'樹來查看裏面有什麼?在Exchange Web服務中,我不認爲它通過名稱來鍵入它們,而是通過ID來鍵入它們,並且您必須使用單獨的函數來按名稱查找它們。 – Origin
是的,我正在使用調試器,並且無處可尋!然而,我在Sue Mosher的舊網站www.outlookcode.com找到了一個解決方案,您是對的,我需要一個功能,我現在將代碼放入... –