Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Extract attachment from a folder of emails

Posted on 2009-03-30
6
369 Views
Last Modified: 2012-05-06
Hi everyone,

I have put about 100 emails with attachments into a folder in Outlook (I think it's 2007 but it could be 2003) and I'm trying to find out if there's an easy way to extract all of the attachments in one go and have them land in another folder on my desktop.

Can someone tell me if there's some sort of command or something in Outlook that allows you to do this?

Really appreciate any advice.
0
Comment
Question by:gwh2
6 Comments
 
LVL 66

Expert Comment

by:johnb6767
ID: 24025694
Welcome to Todi !
The To-Disk-Saver Outlook Add-In for Attachments
http://www.aufgang.org/koch/homepage/software/todi.htm#7

Not sure if it supports Office 2007 yet.... 2003 I believe so....
0
 
LVL 28

Expert Comment

by:peakpeak
ID: 24025892
0
 
LVL 10

Accepted Solution

by:
Madjax earned 500 total points
ID: 24025952
Hello
Here is a nice code that I use in my Outlook.
It extracts attachments from emails and sorts then by sender and date/time in a specified folder.
To install the script you press ALT+F11 and create a new module and then paste the content into that. Save it after.
Once in place you need to create a Outlook rule for it so you can choose to have it on all incming mail or just some.  
Change this row> Const BASE_PATH = "H:\\MailAttachments\\" to what you like to have it stored. You need to have the folder created first.

Sub StripAttachments(Item As Outlook.MailItem)
 
On Error GoTo EarlyBath
 
Const BASE_PATH = "H:\\MailAttachments\\"
 
If Item.Class = olMail Then
    If Item.Attachments.Count > 0 Then
        Dim objAtt As Outlook.Attachments
        Set objAtt = Item.Attachments
        For Each objattach In objAtt
            Dim i, lngCounter As Long
            Dim strLogger, strFile, strLocalFileLink, strLocalPath, strUser, strFolder As String
 
            
            lngCounter = Item.Attachments.Count
            'Debug.Print lngcounter
            strLogger = "-------------------------------------------------------------------------------------------------"
                                    
            'organise folders by sender
            strFolder = BASE_PATH & Item.SenderName & "\\"
            
            If Dir(strFolder, vbDirectory) = "" Then
                MkDir (strFolder)
            End If
            
            'organise subfolder by received date
            strFolder = strFolder & Strings.Format(Item.ReceivedTime, "ddmmyyyy") & "\\"
            
            If Dir(strFolder, vbDirectory) = "" Then
                MkDir (strFolder)
            End If
            
            
            'create and display link to dest folder
            strLocalPath = "file://" & Replace(strFolder, " ", "%20")
            strLocalPath = Replace(strLocalPath, "\\", "\")
            strLogger = strLogger & vbCrLf & "Attachment Path: " & strLocalPath & vbCrLf
            strLogger = strLogger & vbCrLf & "The following attachments have been stripped from this message:"
            
            
            
            'move through the attachments, saving the file, deleting from msg body and inserting links
            For i = lngCounter To 1 Step -1
            
                strFile = objAtt.Item(i).FileName
                If Len(strFile) > 0 Then
                    Dim trimLen: trimLen = Len(strFile) - InStrRev(strFile, ".")
                    Dim time As String
                    time = Format(Now(), "hhmm")
                    strFile = strFolder & "\\" & time & "_" & strFile
                    objAtt.Item(i).SaveAsFile strFile
                    objAtt.Item(i).Delete
                    strLocalFileLink = Replace(strFile, "\\", "\")
                    strLocalFileLink = "file://" & Replace(strLocalFileLink, " ", "%20")
                
                    strLogger = strLogger & vbCrLf & vbCrLf & "Attachment " & lngCounter & ": " & strLocalFileLink
                Else
                End If
                    'strLogger = ""
SkipAtt:
            Next i
            
            strLogger = strLogger & vbCrLf & "-------------------------------------------------------------------------------------------------" & vbCrLf
            
            Item.Body = strLogger & Item.Body
            Item.Save
        Next
            Set objAtt = Nothing
        
    End If
End If
EarlyBath:
Exit Sub
End Sub
 
    

Open in new window

0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 10

Expert Comment

by:Madjax
ID: 24025959
oh  I forgot....the script also modifies the original email and says it stripped the attactment out and provides a link to where it is.
0
 
LVL 1

Author Comment

by:gwh2
ID: 24026210
Thanks for all the replies.

Madjax: I wanted to give your vba code a try - If all the emails have been put into a particular folder within Outlook, how do you run the macro on just that folder and not anything-else?
0
 
LVL 10

Expert Comment

by:Madjax
ID: 24046477
you can run the outlook rule on any specified folder. When you wanna run the rule, you're asked where you wanna run it.
thanks for the points
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question