Getting "Run-time error '-2147024864 (80070020) which saving outlook attachment on arrival

本秂侑毒 提交于 2019-12-12 02:44:11

问题


I run below script to save Outlook attachment on arrival of email. But I frequently get Run-time error '-2147024864 (80070020), which will always stop the inflow of Outlook email. Please advise how to get rid.

Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Email\"

     For Each objAtt In itm.Attachments

          objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName

          Set objAtt = Nothing
     Next
End Sub


回答1:


try this code please

it prints the name of each attachment before it saves the attachment

press ctrl-G to see "immediate window" where the printout is sent

check the last file name printed when the program crashes

it may provide some insight

Sub saveAttachtoDisk(itm As Outlook.MailItem)
    Dim objAtt As Outlook.Attachment
    Dim saveFolder As String
    saveFolder = "C:\Email\"

    For Each objAtt In itm.Attachments

        debug.print objAtt.DisplayName        ' print attachment name to "immediate window"

        objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName

    Next
    Set objAtt = Nothing
End Sub


来源:https://stackoverflow.com/questions/44621280/getting-run-time-error-2147024864-80070020-which-saving-outlook-attachment

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!