1
我已经构建了一个VBA项目,用于检查特殊电子邮件上的收件箱,
提取附件并将附件保存在网络上。
这一切都发生在用户点击按钮时。展望2013收到邮件
我现在的问题是我想自动化这个。
所以我试图重写VBA项目,但
当电子邮件到达时,我总是得到错误信息
“Unzulässiger奥德nicht ausreichend defnierter Verweis”
(TR。不当,或没有足够的定义的参考)
我不知道该怎么做,因此我试图
在这里得到答案。
附,你会发现这是摆在 'ThisOutlookSession' 代码
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim objNs As Outlook.NameSpace
Dim X As Integer
Set objNs = GetNamespace("MAPI")
Set Items = objNs.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
Dim objNs As Outlook.NameSpace
Dim strPath, strAuditPath, strSavPath, strFolderName As String
Dim oAttachment As Outlook.Attachment
Dim objTrash As Outlook.Folder
Dim intAnlagen, intTotal, i As Integer
Set objNs = GetNamespace("MAPI")
On Error GoTo check_error
If TypeOf Item Is Outlook.MailItem Then
Dim Msg As Outlook.MailItem
Set Msg = Item
If Msg.SenderEmailAddress = "[email protected]" Then
If Left(Msg.Subject, 8) = "QHST-Log" Then
strSavPath = "D:\Users\AS400_QHST_Logs\"
strPath = "T:\DOKUMENTE\AS400\QHST-Logs\"
strAuditPath = "D:\Dropbox\QHST-Log\"
strFolderName = Right(Msg.Subject, 4)
If Dir(strPath & strFolderName, vbDirectory) = vbNullString Then 'Prüfen ob Subfolder der Form JJJJ angelegt ist.
MkDir strPath & strFolderName
MkDir strAuditPath & strFolderName
MkDir strSavPath & strFolderName
End If
strPath = strPath & strFolderName & "\"
strAuditPath = strAuditPath & strFolderName & "\"
strSavPath = strSavPath & strFolderName & "\"
strFolderName = Mid(.Subject, 14, 2)
If Dir(strPath & strFolderName, vbDirectory) = vbNullString Then
MkDir strPath & strFolderName
MkDir strAuditPath & strFolderName
MkDir strSavPath & strFolderName
End If
strPath = strPath & strFolderName & "\"
strAuditPath = strAuditPath & strFolderName & "\"
strSavPath = strSavPath & strFolderName & "\"
intAnlagen = Msg.Attachments.Count
intTotal = intTotal + intAnlagen
'Debug.Print objNewMail & ": "; intanlagen
If intAnlagen > 0 Then
For i = 1 To intAnlagen
Set oAttachment = Msg.Attachments.Item(i)
oAttachment.SaveAsFile strPath & oAttachment.FileName
oAttachment.SaveAsFile strAuditPath & oAttachment.FileName
Next i
End If
Msg.UnRead = False
Msg.Delete
End If
End If
End If
check_error:
Debug.Print Err.Number; Err.Description
If Err.Number = 75 Then
Err.Clear
GoTo Back1:
Else
Err.Raise Err.Number, Err.Description
End If
Err.Clear
Resume Next
End Sub
ich spreche kein Deutsch –
尝试将所有德语改为英语,因为英语更常见,因此更多人可以提供帮助。还有,如果你还没有做到这一点错误发生在哪里? – Alex
@Alex - 新邮件到达语句时发生错误:Private Sub Items_ItemAdd(ByVal Item As Object) – neurieser