我跑在每一個下面的代碼接收的電子郵件:前景VBA腳本錯誤
Dim globalWrongExt As Boolean
Dim globalcontainsZip As Boolean
Dim globalTotalSize As Double
Sub sortingP8(Item As Outlook.MailItem)
'Check each attachment
globalTotalSize = 0
globalcontainsZip = False
globalWrongExt = False
Set ns = Application.GetNamespace("MAPI")
Set nonIngFolder = ns.Folders("[email protected]").Folders("Non-ingestible Items")
Set ingFolder = ns.Folders("[email protected]").Folders("Ingestible Items")
Set zipFolder = ns.Folders("[email protected]").Folders("ZIP files")
'Check extensions
extensionCheck Item
'Move email to the appropiate folder
If (globalWrongExt = True Or globalTotalSize > 10000000) Then
Item.Move nonIngFolder
ElseIf (globalcontainsZip = True) Then
Item.Move zipFolder
Else
Item.Move ingFolder
End If
End Sub
Private Sub extensionCheck(Item As Outlook.MailItem)
Dim olkAtt As Outlook.Attachment
'Check each attachment
For Each olkAtt In Item.Attachments
Dim extension As String
extension = Right(LCase(olkAtt.FileName), 4)
'If the attachment's file name ends with .zip
globalTotalSize = globalTotalSize + olkAtt.Size
If extension = ".msg" Then
extensionCheck olkAtt
ElseIf extension <> ".ppt" And extension <> ".doc" And extension <> ".pdf" And extension <> ".jpg" And extension <> ".zip" And extension <> ".docx" And extension <> ".pptx" And extension <> ".htm" And extension <> ".html" And extension <> ".gif" And extension <> ".tif" Then
globalWrongExt = True
ElseIf extension = ".zip" Then
globalcontainsZip = True
End If
Next
End Sub
調試時,下面的行失敗:
If extension = ".msg" Then
**extensionCheck olkAtt**
是否有可能投的olkAtt對象一個Outlook.MailItem。
或者也許是腳本的解決方法。我想要實現的是在每個.msg附件中調用的遞歸函數來評估附件中包含的附件。
異常的輸出是什麼? –
剛運行時錯誤'13': 類型不匹配 – user3270648