我无法从Outlook下载文件。出现错误“无法保存附件。您没有适当的权限” 。在下面的行中给出了抛出错误。
ATMT.SaveAsFile“ C:\ Users \ p2018 \ Desktop \ mail文件夹”
也共享代码
Sub ExtracFiles()
Dim O As Outlook.Application
Set O = New Outlook.Application`
Dim ONS As Outlook.Namespace
Set ONS = O.GetNamespace("MAPI")
Dim Fol As Outlook.Folder
Set Fol = ONS.GetDefaultFolder(olFolderInbox).Folders("Weekly Compliance
Report")
Dim OMAIL As Outlook.MailItem
Set OMAIL = O.CreateItem(olMailItem)
Dim ATMT As Outlook.Attachment
Dim mydate As Date
mydate = Format(Date, "mm-dd-yyyy")
For Each OMAIL In Fol.Items
For Each ATMT In OMAIL.Attachments
If
OMAIL.SenderEmailAddress="PeopleGroup@Check.com" And _
Format(OMAIL.ReceivedTime, _
"mm-dd-yyyy") = mydate Then
ATMT.SaveAsFile "C:\Users\p2018\Desktop\mail folder"
MsgBox ATMT
Else
End If
Next ATMT
Next OMAIL
End Sub
答案 0 :(得分:0)
您必须指定标准文件名,而不仅仅是路径:
ATMT.SaveAsFile "C:\Users\p2018\Desktop\mail folder\" & ATMT.FileName
答案 1 :(得分:0)
再次提出这个问题,但我整个上午都遇到了同样的错误。
原来有一个文件与 Outlook 附件的名称完全相同,所以它不会让我覆盖它。
使用不同的名称保存附件效果很好。