我已经设置了将电子邮件附件下载到我的PC的代码。 但现在我陷入了要在PC上不同位置下载特定电子邮件附件的问题
答案 0 :(得分:0)
这应该使您入门。将其放在Outlook中的模块中。您将需要更改文件夹信息等。
Public Sub SaveAttachmentsToDisk()
Dim currentExplorer As Explorer
Dim currentSelection As Selection
Dim ndxItem As Outlook.MailItem
Dim attachFile As Outlook.Attachment
Const SaveFolder As String = "C:\OutlookAttachments\"
Set currentExplorer = Application.ActiveExplorer
Set currentSelection = currentExplorer.Selection
If currentSelection.Count <= 0 Then Exit Sub
If TypeName(currentSelection.Item(1)) <> "MailItem" Then Exit Sub
For Each ndxItem In currentSelection
Debug.Print ndxItem.Body
For Each attachFile In ndxItem.Attachments
If VBA.Right$(attachFile.DisplayName, 3) <> "jpg" And VBA.Right$(attachFile.DisplayName, 3) <> "png" Then
attachFile.SaveAsFile SaveFolder & attachFile.FileName
End If
Next attachFile
Next ndxItem
End Sub