Log in

View Full Version : Outlook VBA: Move/Copy nested PDF files in attached emails to folder on desktop.



marame
06-04-2019, 07:50 AM
I regularly receive one email that has 50 or more emails attached to it. Each of those attached emails in turn has a PDF file attached to it. It is extremely time consuming to open the primary email, then open each individual attached email, then drag/copy each nested PDF file to a desktop folder.

Could someone kindly post VBA code that will copy all nested file attachments from the attached emails to a desktop folder. I have tried to adapt various code I've found but so far I am not getting anywhere.

PaulAJ4
06-26-2019, 10:25 AM
Hi, I had the exact same problem and noticed that no one had answered you here, so when I figured out a solution, I figured I'd share it. For this to work, you'll have to copy and paste all the attached emails to a dedicated folder in your Outlook. Then, when you run the macro, it will prompt you to select a folder, and you just select whatever folder you put them in. You should make sure the folder only contains the emails you want to run the macro on, as it will run on every message in the folder. Make sure to put the path of the folder where you want your files to go in "quotes" after the equal sign in the macro before running it. This is also set up to save the attachment as a .pdf with its original name.



Sub SaveAttachments()
Dim Inb As Folder
Dim Msg As MailItem
Dim Att As Attachment
Dim Name As String
Dim Path As String

Set Inb = Outlook.Session.PickFolder
Path =

On Error Resume Next
For Each Msg In Inb.Items
For Each Att In Msg.Attachments
Name = Att.FileName
Att.SaveAsFile Path & Name & ".pdf"
Next Att
Next Msg
End Sub

Weevr123
09-15-2022, 11:50 PM
I am having the same problem but i cant use macros is there a way to do this with out using a macro.



Hi, I had the exact same problem and noticed that no one had answered you here, so when I figured out a solution, I figured I'd share it. For this to work, you'll have to copy and paste all the attached emails to a dedicated folder in your Outlook. Then, when you run the macro, it will prompt you to select a folder, and you just select whatever folder you put them in. You should make sure the folder only contains the emails you want to run the macro on, as it will run on every message in the folder. Make sure to put the path of the folder where you want your files to go in "quotes" after the equal sign in the macro before running it. This is also set up to save the attachment as a .pdf with its original name.



Sub SaveAttachments()
Dim Inb As Folder
Dim Msg As MailItem
Dim Att As Attachment
Dim Name As String
Dim Path As String
Set Inb = Outlook.Session.PickFolder
Path =
On Error Resume Next
For Each Msg In Inb.Items
For Each Att In Msg.Attachments
Name = Att.FileName
Att.SaveAsFile Path & Name & ".pdf"
Next Att
Next Msg
End Sub

Sergioff
05-29-2023, 10:43 AM
Hi,
Can You tell me, how to to change the PickFolder to "Selected messages" in this Macro?:help