Excel VBA Introduction Part 29.8 - Saving Attachments from an Outlook Folder

Share
Embed
  • Loading...
  • Published on:  Tuesday, April 23, 2019
  • By Andrew Gould

    https://www.wiseowl.co.uk - This video explains how to save the attachments from a collection of emails in an Outlook folder. You'll learn how to identify which emails have attachments, how to loop over the attachments collection and how to use the SaveAsFile method. You'll also see how to use a FileSystemObject to create a new folder for each email's attachments collection.

    You can download the completed file here https://www.wiseowl.co.uk/vba-macros/videos/vba-outlook/save-attachments-outlook/

    If you'd like to help fund Wise Owl's conversion of tea and biscuits into quality training videos, you can click this link https://www.wiseowl.co.uk/donate?t=1 to make a donation. Thanks for watching!

    You can buy our Introduction to Excel VBA book here http://www.lulu.com/shop/andrew-gould/introduction-to-excel-vba/paperback/product-23301058.html

    Visit www.wiseowl.co.uk for more online training resources in Microsoft Excel, SQL Server, Reporting Services, Analysis Services, Integration Services, ASP.NET, C#, Visual Basic, Microsoft Access, Microsoft PowerPoint, Microsoft Word, Microsoft Project, Microsoft Publisher, Microsoft Visio and more
  • Source: https://youtu.be/6EGhTg1o2qA
Loading...

Comment

  • Pradeep Rawat

     (Apr 23, 2019)

    Thank you so much sir for giving us such a valuable knowledge without any charges with the help of you we can boost our career and knowledge too🙏🙏🙏🙏🇮🇳

  • Pradeep Rawat

     (Apr 23, 2019)

    You’re my favourite sir

  • WiseOwlTutorials

     (Apr 23, 2019)

    You're welcome! Thanks for the comments and for watching!

  • krn14242

     (Apr 28, 2019)

    Thanks Andrew, great stuff

  • John Mutethia

     (Apr 24, 2019)

    you are excelent! watching from KENYA

  • WiseOwlTutorials

     (Apr 24, 2019)

    Asante sana John!

  • José Ricardo Oña

     (May 9, 2019)

    You have an amazing channel... thank u for sharing

  • WiseOwlTutorials

     (May 9, 2019)

    Thank you for watching José, and for taking the time to leave a comment!

  • Kashif Khan

     (Apr 24, 2019)

    Hi Andrew,Thank you so much for the tutorial, now I have the idea that how can I play with the attachments.Thanks once again.ThanksKashif

  • WiseOwlTutorials

     (Apr 24, 2019)

    You're welcome Kashif! This video doesn't solve the problem of distinguishing between attachments and embedded images but I'm getting to it!

  • Vengion

     (Apr 23, 2019)

    You are awesome. Thank you so much for these videos.

  • WiseOwlTutorials

     (Apr 23, 2019)

    You're awesome, thanks for watching!

  • panner selvam maruthachalam

     (Apr 23, 2019)

    Hi sir thank you so much can you give us same code in early binding method please

  • WiseOwlTutorials

     (Apr 24, 2019)

    Hi Panner, the video does already show the early binding method - we set a reference to the Outlook and Scripting Runtime object libraries to make use of the object models in the Intellisense list. If it's late binding that you're after, we've got you covered for that too! The code below assumes you've removed the references to the Outlook and Scripting Runtime object libraries (I'll post a link to a file that you can download when I get back to the office next week!):Sub SaveOutlookAttachmentsLat...

  • Sasi Kumar

     (Apr 23, 2019)

    Thank you very much sir🙏🏻I’ve learned a lot...could you please help to make a video for PDF macros using VBA (pull specific data from pdf and paste into excel)

  • Sasi Kumar

     (Apr 24, 2019)

    WiseOwlTutorials Thank you very much sir🤝...I will go through the above link now...however you will post a video for upcoming season.

  • WiseOwlTutorials

     (Apr 24, 2019)

    You're very welcome Sasi! That topic is on my list but it may take some time to get to it - in the meantime, here's a couple of examples:https://stackoverflow.com/questions/36270247/extract-data-from-pdf-and-add-to-worksheet/54131180http://www.vbaexpress.com/kb/getarticle.php?kb_id=1101Thanks for watching!

  • Abhishek Saraswat

     (5 days ago)

    Hi Andrew, How we can download the attachment from the particular email or specific time period. for example: Someone share the excel files from last 2 month, and i want to save all the attachment of that specific email id for only last month. It can be possible. if Yes please help us.

  • WiseOwlTutorials

     (4 days ago)

    Hi Abishek, you can use the Restrict method to filter the list of emails. This page has some examples of using Restrict with dates if you scroll down far enough! https://docs.microsoft.com/en-us/office/vba/api/Outlook.Items.RestrictThere's also a nice example of a procedure using this in the accepted answer on this page https://stackoverflow.com/questions/38310690/outlook-items-restrict-with-date-issueI hope that helps!

  • David Megnin

     (Apr 24, 2019)

    Great video. Nice clear instructions. Thank you!I followed them very carefully and I'm getting "An object could not be found" Run-time error on the Set fol = ns.Folders(1).Folders("David") line.I did add the reference to the Microsoft Outlook and double checked it. I checked the folder name.What could be the problem?Option ExplicitSub SaveOutlookAttachements()Dim ol As Outlook.ApplicationDim ns As Outlook.NamespaceDim fol As Outlook.FolderDim i As ObjectDim mi As...

  • WiseOwlTutorials

     (Apr 24, 2019)

    Great that you got it to work eventually! Thanks for the update and let us know if you have any other issues!

  • David Megnin

     (Apr 24, 2019)

    Well, I guess our organization is kind of odd. This is what worked for my Outlook folder structure:Set fol = ns.Folders(2).Folders("Inbox").Folders("David")Yeah, Folders(2)This video was extremely helpful. Thanks for the link to it. https://youtu.be/tKNYgF2AKu0Thank you again for the great videos!