Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript to save attachment from Outlook only saves 2 emails?

Status
Not open for further replies.

travelnitwit

Technical User
Oct 11, 2013
5
US
I have this script to auto save attachments from outlook in a folder but it only saves attachments from 2 emails at a time. How do I increase this to 3 or 4?

Code:
Const olFolderInbox = 6

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objMailbox = objNamespace.Folders("Mailbox - ABC")
Set objFolder = objMailbox.Folders("Inbox")

Set colItems = objFolder.Items
Set colFilteredItems = colItems.Restrict("[UnRead] = True")

For Each objMessage in colFilteredItems
    intCount = objMessage.Attachments.Count
    If intCount > 0 Then
        For i = 1 To intCount
            objMessage.Attachments.Item(i).SaveAsFile "C:\" &  _
                objMessage.Attachments.Item(i).FileName
        Next 
    End If
    objMessage.Unread = False
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top