Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6093717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:35:34+00:00 2026-05-23T12:35:34+00:00

I built a script that downloads all the attachments in a particular outlook inbox,

  • 0

I built a script that downloads all the attachments in a particular outlook inbox, but I need to modify it so it will only grab emails that fall within a particular date range.

Here’s my code for downloading all the attachments in the folder:

Sub DlAttachments()
    MsgBox ("Cross fingers and click button to start download.")
    Set objOutlook = CreateObject("Outlook.Application")
    Set objNamespace = objOutlook.GetNamespace("MAPI")

    strFolderName = "Special Inbox Admin"
    Set objMailbox = objNamespace.Folders(strFolderName)
    Set objFolder = objMailbox.Folders("Inbox")

    Set colItems = objFolder.Items

    For Each objMessage In colItems
        intCount = objMessage.Attachments.Count
        If intCount > 0 Then
            For i = 1 To intCount
                objMessage.Attachments.Item(i).SaveAsFile "C:\SP_INBOX_DUMP_temp\" & objFolder & "_" & _
                    objMessage.Attachments.Item(i).FileName
            Next
        End If
    Next

    MsgBox ("Download complete. Files downloaded to C:\SP_INBOX_DUMP_temp\")
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:35:35+00:00Added an answer on May 23, 2026 at 12:35 pm

    You can use the SentOn property of the object message. That would change your code to :

    Dim myDate as Date
    
    For Each objMessage In colItems
        intCount = objMessage.Attachments.Count
        'get the sent date
        sentDate = objMessage.SentOn
        'ref date (adapt format to your system date format dd/mm/yyyy or mm/dd/yyyy)
        myDate = dateValue("31/1/2009")   
        If myDate > sentDate Then
            'do whatever --> Exit For ?
        End If
        If intCount > 0 Then
            For i = 1 To intCount
                objMessage.Attachments.Item(i).SaveAsFile "C:\SP_INBOX_DUMP_temp\" & objFolder & "_" & _
                    objMessage.Attachments.Item(i).FileName
            Next
        End If
    Next
    

    Regards,

    Max

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python script that uses built-in modules but also imports a number
I'm trying to create a script that will download a dynamically built Initializr zip
I need to create an application for the iPhone that will connect to a
I am writing a script that parses an internet site (maya.tase.co.il) for links, downloads
I've written a PHP script that handles file downloads, determining which file is being
We all know that Mathematica is great, but it also often lacks critical functionality.
I am in the process of working on a perl script that will connect
I'm pretty new to javascript, and has built a script that is working in
I'm using a build script that calls Wise to create some install files. The
I have a utility build script that gets called from a variety of project-specific

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.