outlook中vba代码报错,求指导!
报错如图画圈所示,这个不是vba提供的函数吗,以下是完整的代码,求帮忙看看,改成正确的PrivateSubApplication_NewMailEx(ByValEntry...
报错如图画圈所示,这个不是vba提供的函数吗,以下是完整的代码,求帮忙看看,改成正确的Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)'//收到邮件后 附件自动保存到指定的路径 Dim varEntryIDs Dim objItem As Outlook.MailItem Dim i As Integer varEntryIDs = Split(EntryIDCollection, ",") '//获得邮件的ID号 唯一的 For i = 0 To UBound(varEntryIDs) Set objItem = Application.Session.GetItemFromID(varEntryIDs(i)) '//根据ID号 获得整个邮件 Call NewMailSaveAttachements(objItem) '//附件的处理 Next '// MsgBox "你共收到" & UBound(varEntryIDs) & "邮件 "End SubSub NewMailSaveAttachements(myMail As Outlook.MailItem)'// outlook 收到新邮件是 将邮件的附件 自动放到指定位置 On Error Resume Next Dim mail As Outlook.MailItem Dim Fso As Object Dim myOlExp As Outlook.Explorer '//outlook Dim myOlSel As Outlook.Selection '//outlook所在选择项 Set Fso = CreateObject("Scripting.FileSystemObject") '//FSO文件对象 Dim MsgTxt As String Dim x As Integer Dim Folder As String Dim reg As String Dim MyFileName As String Dim myT1, myT2, myT3, myT As String Set myOlExp = Application.ActiveExplorer '//指向对象 outlook '// Set myOlSel = myOlExp.Selection Dim vItem As Outlook.Attachment reg = "\d+" '//正则表达式 If myMail.Attachments.Count > 0 Then For i = 1 To myMail.Attachments.Count myT1 = CStr(Format(myMail.SentOn, "yyyymmdd")) myT2 = myMail.SenderName Set vItem = myMail.Attachments(i) MyFileName = vItem.FileName myT = path0 & "\" & myT1 & "-" & myT2 & "-" & MyFileName '//Debug.Print MyFileName If InStr(MyFileName, "思考A3") = 0 Or InStr(MyFileName, "广发纳斯特乐睿1号") = 0 Then '//判断是否包含该月份的文件夹,有则保存在文件夹 ,无则创建文件 Folder = "E:\outlook\" & Val(Mid(getRegtoString(reg, MyFileName), 5, 2)) & "月份" '//判断月份 If Not Fso.FolderExists("Folder") Then '//无则创建文件夹 Fso.CreateFolder (Folder) End If vItem.SaveAsFile Folder & "\" & vItem.FileName '//保存附件路径 Else vItem.SaveAsFile "E:+\outlook\down\" & vItem.FileName '//保存到根目录文件夹 End If Next i End IfEnd Sub
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询