Consulting

Results 1 to 2 of 2

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

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

    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.

  2. #2
    VBAX Newbie
    Joined
    Jun 2019
    Posts
    1
    Location
    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
    Last edited by PaulAJ4; 06-26-2019 at 12:27 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •