Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2014, 04:44 PM
Joey Cheung Joey Cheung is offline Way to save all attachments form multiple emails at once Windows 7 64bit Way to save all attachments form multiple emails at once Office 2010 64bit
Novice
Way to save all attachments form multiple emails at once
 
Join Date: Aug 2014
Posts: 10
Joey Cheung is on a distinguished road
Default Way to save all attachments form multiple emails at once

Hi everyone,

I am looking for a way to save all of the attachments from multiple emails at once (without opening each of the emails and save the attachments one by one).

Are there any built-in function in Outlook 2010 for me to do so?

Thanks a lot!
Reply With Quote
  #2  
Old 12-06-2014, 04:12 AM
gmayor's Avatar
gmayor gmayor is offline Way to save all attachments form multiple emails at once Windows 7 64bit Way to save all attachments form multiple emails at once Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

There is no built-in function, but you can do it with a few macros e.g. as follows. Change the path to where you want to save the attachments. On a large folder this could take some time to run.

Code:
Option Explicit

Sub SaveAttachments()
Const strPath As String = "C:\Path\Message Attachments\"
Dim strFilename As String
Dim olFolder As Folder
Dim olItem As MailItem
Dim olAttach As Attachment
Dim i As Long
    MsgBox "Wait for 'Process Complete Message'"
    CreateFolders strPath        'Create the folder if it doesn't exist
    Set olFolder = Application.Session.PickFolder
    olFolder.Items.Sort "[Received]", True
    For i = 1 To olFolder.Items.Count
        Set olItem = olFolder.Items(i)
        If olItem.Attachments.Count > 0 Then
            For Each olAttach In olItem.Attachments
                If Not olAttach.Filename Like "image*.*" And _
                   Not olAttach.Filename Like "Untitled attachment*.*" Then
                    strFilename = olAttach.Filename
                    strFilename = FileNameUnique(strPath, _
                                                 strFilename, _
                                                 Right(strFilename, Len(strFilename) - InStrRev(strFilename, Chr(46))))
                    olAttach.SaveAsFile strPath & strFilename
                End If
            Next olAttach
        End If
        DoEvents
    Next i
    MsgBox "Process Complete"
    Set olFolder = Nothing
    Set olAttach = Nothing
    Set olItem = Nothing
    Exit Sub
End Sub

Private Function FileNameUnique(strPath As String, _
                               strFilename As String, _
                               strExtension As String) As String
Dim lngF As Long
Dim lngName As Long
    lngF = 1
    lngName = Len(strFilename) - (Len(strExtension) + 1)
    strFilename = Left(strFilename, lngName)
    Do While FileExists(strPath & strFilename & Chr(46) & strExtension) = True
        strFilename = Left(strFilename, lngName) & "(" & lngF & ")"
        lngF = lngF + 1
    Loop
    FileNameUnique = strFilename & Chr(46) & strExtension
lbl_Exit:
    Exit Function
End Function

Private Function CreateFolders(strPath As String)
Dim strTempPath As String
Dim lngPath As Long
Dim vPath As Variant
    vPath = Split(strPath, "\")
    strPath = vPath(0) & "\"
    For lngPath = 1 To UBound(vPath)
        strPath = strPath & vPath(lngPath) & "\"
        If Not FolderExists(strPath) Then MkDir strPath
    Next lngPath
lbl_Exit:
    Exit Function
End Function

Private Function FolderExists(ByVal PathName As String) As Boolean
Dim lngAttr As Long
    On Error GoTo NoFolder
    lngAttr = GetAttr(PathName)
    If (lngAttr And vbDirectory) = vbDirectory Then
        FolderExists = True
    End If
NoFolder:
    Exit Function
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Way to save all attachments form multiple emails at once Problems sending emails w/attachments Beckymonet Outlook 1 12-04-2014 10:20 PM
Way to save all attachments form multiple emails at once Bulk emails with individual attachments. sureshpunna Excel Programming 2 07-10-2014 12:20 AM
Way to save all attachments form multiple emails at once Bulk emails with individual attachments. sureshpunna Outlook 1 07-07-2014 10:25 AM
Saving Emails to New Folder along with Attachments thundercats9595 Outlook 2 02-01-2014 12:32 PM
Way to save all attachments form multiple emails at once Printing Emails and attachments glow worm Outlook 1 06-28-2011 12:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft