Vba 从邮件下载pdf文档一个文档上出现错误:“;无法保存附件。操作失败。找不到对象";
我正在尝试将pdf文档从特定的电子邮件ID地址下载到Box_文件夹 我犯了这个错误 无法保存附件。操作失败。找不到对象 在这一行Vba 从邮件下载pdf文档一个文档上出现错误:“;无法保存附件。操作失败。找不到对象";,vba,outlook,Vba,Outlook,我正在尝试将pdf文档从特定的电子邮件ID地址下载到Box_文件夹 我犯了这个错误 无法保存附件。操作失败。找不到对象 在这一行Atmt.SaveAsFile FileName 似乎某个特定日期的PDF文档无法打开它。我认为pdf错误-也无法手动打开 在7855封邮件的小计邮件文件夹中,几乎有5083封邮件自动下载到“盒子文件夹”中,但最后,这是由于错误 Sub Saveattachment() Application.ScreenUpdating = False Applic
Atmt.SaveAsFile FileName
似乎某个特定日期的PDF文档无法打开它。我认为pdf错误-也无法手动打开
在7855封邮件的小计邮件文件夹中,几乎有5083封邮件自动下载到“盒子文件夹”中,但最后,这是由于错误
Sub Saveattachment()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim lngCount As Long
Dim filepath As Variant
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = "C:\"
.Show
' Display paths of each file selected
If .SelectedItems.Count > 0 Then
filepath = .SelectedItems(1) & "\"
Else
Exit Sub
End If
End With
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.Namespace
Dim olItem As Outlook.MailItem
Dim i As Integer
Dim b As Integer
Dim olInbox As Outlook.MAPIFolder
Dim olFolder As Outlook.MAPIFolder
Dim lngCol As Long
Dim oMsg As Outlook.MailItem
Dim mainWB As Workbook
Dim keyword
Dim Count
Dim Atmt
Dim f_random
Dim FileName
Dim foldernew As String
'Dim olInbox As inbo
Set olApp = New Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")
Set olInbox = olNamespace.GetDefaultFolder(Outlook.olFolderInbox)
Set olInbox = olInbox.Folders("Tax PDF")
Dim oItems As Outlook.Items
Set oItems = olInbox.Items
'Subject of mail
keyword = "noreply@XXXX.XXX.in"
For i = 1 To oItems.Count
If TypeName(oItems.Item(i)) = "MailItem" Then
Set oMsg = oItems.Item(i)
If InStr(1, oMsg.Sender.GetExchangeUser.PrimarySmtpAddress, keyword, vbTextCompare) > 0 Then
For Each Atmt In oMsg.Attachments
FileName = filepath & Atmt.FileName
If Right(FileName, 3) = "PDF" Then
Atmt.SaveAsFile FileName
End If
Next Atmt
End If
End If
Next
MsgBox "Files has been Moved to Respective Folder", vbInformation, "Excel to Outlook"
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
错误在哪一行?这句话的意思是什么“在7855的电子邮件小计文件夹中,几乎5083封电子邮件自动下载到“Box Folder”,但时间结束时,它是错误的。“我很难理解它。”运行时错误“-2147221233(8004010f)“:无法保存附件操作失败,找不到对象抱歉,这意味着我们在下创建了新文件夹,在收件箱中,我们设置了将所有电子邮件移动到子文件夹的规则,到目前为止,总共7855个,当我运行宏时,几乎5083个文档移动到了本地路径..似乎是相同的XXAAA.pdf多次被覆盖了,是吗为什么会出现此运行时错误?错误发生在哪一行?听起来好像消息在循环执行时被删除/移动了。@Dmitry Streblechenko,今天如何避免此错误,我注意到出现了错误,“找不到对象”,似乎某个特定日期的PDF文档无法打开它(我认为pdf错误-无法手动打开)错误出现并停止-这一行“Atmt.SaveAsFile FileName”在哪一行是错误?这句话是什么意思“在电子邮件小计文件夹中,7855封电子邮件的数量中,几乎5083封电子邮件自动下载到“Box文件夹”,但时间结束时,这是错误。“我很难理解它。”运行时错误“-2147221233(8004010f)“:无法保存附件操作失败,找不到对象抱歉,这意味着我们在下创建了新文件夹,在收件箱中,我们设置了将所有电子邮件移动到子文件夹的规则,到目前为止,总共7855个,当我运行宏时,几乎5083个文档移动到了本地路径..似乎是相同的XXAAA.pdf多次被覆盖了,是吗为什么会出现此运行时错误?错误发生在哪一行?听起来好像消息在循环执行时被删除/移动了。@Dmitry Streblechenko,今天如何避免此错误,我注意到出现了错误,“找不到对象”,似乎某个特定日期的PDF文档无法打开它(我认为pdf错误-无法手动打开)错误出现并停止-这一行“Atmt.SaveAsFile FileName”