<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Enhancing the Save Attachments Outlook Macro</title>
	<atom:link href="http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/feed/" rel="self" type="application/rss+xml" />
	<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/</link>
	<description>Making Microsoft .Net Development Magical</description>
	<lastBuildDate>Thu, 17 May 2012 06:40:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Santhosh.G</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30724</link>
		<dc:creator><![CDATA[Santhosh.G]]></dc:creator>
		<pubDate>Thu, 10 May 2012 21:05:13 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30724</guid>
		<description><![CDATA[Hi alll.... i was wondering after seeing all your msgs that whether this macro could help me in my work. if not Pls help me in puting a macro for the following work that we carry on.

Overview of the process that we do.

Customer applies for a product online, the details/data comes to the Manager as mails. he then saves those mails as .txt to a common drive, from which we take those cases and proceeds with our work... there would be above 1500cases a day. and its very tough to keep saving each mail that comes in outlook, it takes very long time. while saving a mail we mention the number as well, the file name would be for example:- 1.pepsi,2.pepsi,3.coke..... like wise for each file we add the seriel number to identify the number of cases that comes a day... 

Kindly help me in creating a macro from the outlook to solve this issue, it would be a great help if i could get this done...

THANKS IN ADVANCE..]]></description>
		<content:encoded><![CDATA[<p>Hi alll&#8230;. i was wondering after seeing all your msgs that whether this macro could help me in my work. if not Pls help me in puting a macro for the following work that we carry on.</p>
<p>Overview of the process that we do.</p>
<p>Customer applies for a product online, the details/data comes to the Manager as mails. he then saves those mails as .txt to a common drive, from which we take those cases and proceeds with our work&#8230; there would be above 1500cases a day. and its very tough to keep saving each mail that comes in outlook, it takes very long time. while saving a mail we mention the number as well, the file name would be for example:- 1.pepsi,2.pepsi,3.coke&#8230;.. like wise for each file we add the seriel number to identify the number of cases that comes a day&#8230; </p>
<p>Kindly help me in creating a macro from the outlook to solve this issue, it would be a great help if i could get this done&#8230;</p>
<p>THANKS IN ADVANCE..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: llipaa</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30346</link>
		<dc:creator><![CDATA[llipaa]]></dc:creator>
		<pubDate>Wed, 11 Jan 2012 13:56:13 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30346</guid>
		<description><![CDATA[i also can&#039;t download - is it possible to upload it somewhere?]]></description>
		<content:encoded><![CDATA[<p>i also can&#8217;t download &#8211; is it possible to upload it somewhere?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonas</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30285</link>
		<dc:creator><![CDATA[Jonas]]></dc:creator>
		<pubDate>Thu, 22 Dec 2011 11:32:59 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30285</guid>
		<description><![CDATA[Hi,

I can&#039;t download the script, is there any posibility to get it?.

thanks.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I can&#8217;t download the script, is there any posibility to get it?.</p>
<p>thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30237</link>
		<dc:creator><![CDATA[Bill]]></dc:creator>
		<pubDate>Wed, 07 Dec 2011 19:58:07 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30237</guid>
		<description><![CDATA[Link dead to the full code? 403 error - so may just be permissions..]]></description>
		<content:encoded><![CDATA[<p>Link dead to the full code? 403 error &#8211; so may just be permissions..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wwasin</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30182</link>
		<dc:creator><![CDATA[wwasin]]></dc:creator>
		<pubDate>Mon, 21 Nov 2011 10:20:40 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30182</guid>
		<description><![CDATA[Thanks a lot for this script]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot for this script</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marshall</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30085</link>
		<dc:creator><![CDATA[Marshall]]></dc:creator>
		<pubDate>Fri, 14 Oct 2011 00:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30085</guid>
		<description><![CDATA[Thanks for posting - using this script this will save me hours!]]></description>
		<content:encoded><![CDATA[<p>Thanks for posting &#8211; using this script this will save me hours!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: owenchris</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30077</link>
		<dc:creator><![CDATA[owenchris]]></dc:creator>
		<pubDate>Fri, 07 Oct 2011 22:17:12 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30077</guid>
		<description><![CDATA[Wow, thanks so much!  Amazing. Good input and help from those who got it working.  All the answers are there. The only problem I had was with the reposted code. Use the direct txt link post if possible.]]></description>
		<content:encoded><![CDATA[<p>Wow, thanks so much!  Amazing. Good input and help from those who got it working.  All the answers are there. The only problem I had was with the reposted code. Use the direct txt link post if possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russell</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30066</link>
		<dc:creator><![CDATA[Russell]]></dc:creator>
		<pubDate>Tue, 04 Oct 2011 16:23:24 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-30066</guid>
		<description><![CDATA[I keep getting a Compile error: Syntax error on &quot;outputFile = InputBox(&quot;The file &quot; + outputFile _&quot;
Can anyone offer assistance on what I might be doing wrong.   Thanks]]></description>
		<content:encoded><![CDATA[<p>I keep getting a Compile error: Syntax error on &#8220;outputFile = InputBox(&#8220;The file &#8221; + outputFile _&#8221;<br />
Can anyone offer assistance on what I might be doing wrong.   Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seregduin</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-29642</link>
		<dc:creator><![CDATA[seregduin]]></dc:creator>
		<pubDate>Sun, 17 Jul 2011 22:40:23 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-29642</guid>
		<description><![CDATA[Thanks for your quick response and thank you very much for the code. It is very helpful.]]></description>
		<content:encoded><![CDATA[<p>Thanks for your quick response and thank you very much for the code. It is very helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: arcanecode</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-29636</link>
		<dc:creator><![CDATA[arcanecode]]></dc:creator>
		<pubDate>Sat, 16 Jul 2011 22:26:45 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-29636</guid>
		<description><![CDATA[Not sure why you would have a problem with the link as it seemed to work OK for me, but I just reposted the entire source file on my blog. There is also the non-shortened link to the original code I mentioned embedded in the source. You can find it at: http://arcanecode.com/2011/07/16/revisting-the-outlook-save-all-attachments-macro/]]></description>
		<content:encoded><![CDATA[<p>Not sure why you would have a problem with the link as it seemed to work OK for me, but I just reposted the entire source file on my blog. There is also the non-shortened link to the original code I mentioned embedded in the source. You can find it at: <a href="http://arcanecode.com/2011/07/16/revisting-the-outlook-save-all-attachments-macro/" rel="nofollow">http://arcanecode.com/2011/07/16/revisting-the-outlook-save-all-attachments-macro/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seregduin</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-29619</link>
		<dc:creator><![CDATA[seregduin]]></dc:creator>
		<pubDate>Thu, 14 Jul 2011 00:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-29619</guid>
		<description><![CDATA[Same here. Would love to get this code but the link seems no longer valid. Can anyone help with a new link?]]></description>
		<content:encoded><![CDATA[<p>Same here. Would love to get this code but the link seems no longer valid. Can anyone help with a new link?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: reddragon72</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-29427</link>
		<dc:creator><![CDATA[reddragon72]]></dc:creator>
		<pubDate>Thu, 02 Jun 2011 14:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-29427</guid>
		<description><![CDATA[Was trying to get the txt file for this code and simply cannot. I even started a blog account I will never use to get it and still not being granted access.]]></description>
		<content:encoded><![CDATA[<p>Was trying to get the txt file for this code and simply cannot. I even started a blog account I will never use to get it and still not being granted access.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HeliFox</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-28765</link>
		<dc:creator><![CDATA[HeliFox]]></dc:creator>
		<pubDate>Wed, 29 Dec 2010 04:28:13 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-28765</guid>
		<description><![CDATA[Thanks, I was searching long time for such piece of great code.]]></description>
		<content:encoded><![CDATA[<p>Thanks, I was searching long time for such piece of great code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MikeA</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27988</link>
		<dc:creator><![CDATA[MikeA]]></dc:creator>
		<pubDate>Tue, 21 Sep 2010 06:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27988</guid>
		<description><![CDATA[Thanks for the quick responses guys! Could someone please tell me where in the original Arcane code you are meant to insert the Function code that Josh posted...? Unfortunately I only have a basic VB understanding.

Cheers again :)

Mike]]></description>
		<content:encoded><![CDATA[<p>Thanks for the quick responses guys! Could someone please tell me where in the original Arcane code you are meant to insert the Function code that Josh posted&#8230;? Unfortunately I only have a basic VB understanding.</p>
<p>Cheers again <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27985</link>
		<dc:creator><![CDATA[Jeremy]]></dc:creator>
		<pubDate>Thu, 16 Sep 2010 14:29:44 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27985</guid>
		<description><![CDATA[My apologies - I don&#039;t know VB so I just read other syntax and hacked this version together.  It was only suited for my purposes where I knew that the filename would be four characters long.  I modified (with humble apologies for the format) only one section of the original arcanecode macro:

* * * *
  &#039;Loop thru each selected item in the Inbox
  For cnt = 1 To Sel.Count
    &#039;If the email message has attachments ...
    If Sel.Item(cnt).Attachments.Count &gt; 0 Then
      MsgTotal = MsgTotal + 1
      &#039;For each attachment on the message ...
      For AttachmentCnt = 1 To Sel.Item(cnt).Attachments.Count
        &#039;Get the attachment
        Dim att As Attachment
        Set att = Sel.Item(cnt).Attachments.Item(AttachmentCnt)
        If MsgTotal &lt; 10 Then
            outputFile = Left(att.filename, 4) + &quot;00&quot; + CStr(MsgTotal) + &quot;.pdf&quot;
        ElseIf MsgTotal &lt; 100 Then
            outputFile = Left(att.filename, 4) + &quot;0&quot; + CStr(MsgTotal) + &quot;.pdf&quot;
        Else
            outputFile = Left(att.filename, 4) + CStr(MsgTotal) + &quot;.pdf&quot;
        End If
        att.SaveAsFile (outputDir + outputFile)
        AttTotal = AttTotal + 1
      Next
    End If
  Next
* * * *

Again, it works for me in that it extracts all the attachments and appends a number to the filename but for some reason (with this code and with the original code) it crashes after 100 messages/attachments.  Still haven&#039;t figured that part out yet, tho&#039;.

Cheers,
Jeremy  :)]]></description>
		<content:encoded><![CDATA[<p>My apologies &#8211; I don&#8217;t know VB so I just read other syntax and hacked this version together.  It was only suited for my purposes where I knew that the filename would be four characters long.  I modified (with humble apologies for the format) only one section of the original arcanecode macro:</p>
<p>* * * *<br />
  &#8216;Loop thru each selected item in the Inbox<br />
  For cnt = 1 To Sel.Count<br />
    &#8216;If the email message has attachments &#8230;<br />
    If Sel.Item(cnt).Attachments.Count &gt; 0 Then<br />
      MsgTotal = MsgTotal + 1<br />
      &#8216;For each attachment on the message &#8230;<br />
      For AttachmentCnt = 1 To Sel.Item(cnt).Attachments.Count<br />
        &#8216;Get the attachment<br />
        Dim att As Attachment<br />
        Set att = Sel.Item(cnt).Attachments.Item(AttachmentCnt)<br />
        If MsgTotal &lt; 10 Then<br />
            outputFile = Left(att.filename, 4) + &quot;00&quot; + CStr(MsgTotal) + &quot;.pdf&quot;<br />
        ElseIf MsgTotal &lt; 100 Then<br />
            outputFile = Left(att.filename, 4) + &quot;0&quot; + CStr(MsgTotal) + &quot;.pdf&quot;<br />
        Else<br />
            outputFile = Left(att.filename, 4) + CStr(MsgTotal) + &quot;.pdf&quot;<br />
        End If<br />
        att.SaveAsFile (outputDir + outputFile)<br />
        AttTotal = AttTotal + 1<br />
      Next<br />
    End If<br />
  Next<br />
* * * *</p>
<p>Again, it works for me in that it extracts all the attachments and appends a number to the filename but for some reason (with this code and with the original code) it crashes after 100 messages/attachments.  Still haven&#039;t figured that part out yet, tho&#039;.</p>
<p>Cheers,<br />
Jeremy  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27984</link>
		<dc:creator><![CDATA[Josh]]></dc:creator>
		<pubDate>Thu, 16 Sep 2010 13:44:54 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27984</guid>
		<description><![CDATA[The script opens up the message (and keeps them open) as it iterates over the messages and saves the attachments.  I edited the script so that it processes a subset of the messages at a time and this issue went away.  

I have attached the code below but am not sure how to format it correctly (so apologies for formatting of code).

&lt;pre&gt;
Option Explicit

&#039; Using code from:
&#039; http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/
&#039;       http://arcanecode.files.wordpress.com/2007/01/saveattachments2.txt
&#039; http://www.rondebruin.nl/mail/folder2/saveatt.htm
&#039; http://www.vbaexpress.com/kb/getarticle.php?kb_id=767


Public Sub SaveAttachments()

    &#039; Note, this assumes you are in the a folder with e-mail messages when you run it.
    &#039; It does not have to be the inbox, simply any folder with e-mail messages
    Dim attachmentCount As Integer
    Dim messageCount As Integer


    Dim outlookApp As New Outlook.Application
    Dim folder As Outlook.Explorer
    Set folder = outlookApp.ActiveExplorer


    Dim outputDir As String
    outputDir = GetOutputDirectory()
    If outputDir = &quot;&quot; Then
        MsgBox &quot;You must pick a directory to save your files to. Exiting SaveAttachments.&quot;, vbCritical, &quot;SaveAttachments&quot;
        Exit Sub
    End If


    &#039; Loop thru each selected item in the inbox (100 at a time)
    Const stepSize = 100
    Dim currentIndex As Integer
    currentIndex = 1
    Do While currentIndex &lt; folder.Selection.Count
        Call ProcessChunk(folder.Selection, currentIndex, currentIndex + stepSize - 1, outputDir, attachmentCount, messageCount)
        currentIndex = currentIndex + stepSize
    Loop

    &#039; Clean up
    Set folder = Nothing
    Set outlookApp = Nothing

    &#039; Let user know we are done
    Dim doneMsg As String
    doneMsg = &quot;Completed saving &quot; + Format$(attachmentCount, &quot;#,0&quot;) + &quot; attachments in &quot; + Format$(messageCount, &quot;#,0&quot;) + &quot; Messages.&quot;
    MsgBox doneMsg, vbOKOnly, &quot;Save Attachments&quot;

    Exit Sub

ErrorHandler:

    Dim errMsg As String
    errMsg = &quot;An error has occurred. Error &quot; + Err.Number + &quot; &quot; + Err.Description
    Dim errResult As VbMsgBoxResult
    errResult = MsgBox(errMsg, vbAbortRetryIgnore, &quot;Error in Save Attachments&quot;)
    Select Case errResult
        Case vbAbort
            Exit Sub
        Case vbRetry
            Resume
        Case vbIgnore
            Resume Next
    End Select

End Sub


&#039; Process a &quot;chunk&quot; of the selected messages starting at startIndex and finishing at endIndex.
&#039; The attachments are saved in outputDir and the &#039;statistics&#039; parameters are modified (attachmentCount and messageCount)
Private Sub ProcessChunk(selection As Outlook.selection, _
            startIndex As Integer, endIndex As Integer, outputDir As String, _
            ByRef attachmentCount As Integer, ByRef messageCount As Integer)
    Dim outputFile As String
    Dim msgAttachement As Attachment

    Dim index As Integer
    For index = startIndex To endIndex
        If index &lt;= selection.Count Then
            messageCount = messageCount + 1

            For Each msgAttachement In selection.Item(index).Attachments

                If msgAttachement.Type  olOLE Then
                    outputFile = msgAttachement.filename
                    Dim uniqueFilename As String
                    uniqueFilename = GetUniqueFilename(outputDir, outputFile)
                    msgAttachement.SaveAsFile (outputDir + uniqueFilename)
                    attachmentCount = attachmentCount + 1
                End If
            Next msgAttachement
        End If
    Next index
End Sub


&#039; If the filename already exists, add a counter to the filename (before the extension)
Public Function GetUniqueFilename(directory As String, filename As String) As String
    Dim uniqueFilename As String
    Dim index As Integer

    uniqueFilename = filename
    index = 1
    Do While Not Dir(directory + uniqueFilename) = vbNullString
        uniqueFilename = FileNameNoExtension(filename) + &quot;_&quot; + Format(index, &quot;000&quot;) + &quot;.&quot; + FileNameExtensionOnly(filename)
        index = index + 1
    Loop
    GetUniqueFilename = uniqueFilename
End Function


&#039; returns the filename without the extension from the file&#039;s full path
Function FileNameNoExtension(strPath As String) As String
    Dim strTemp As String
    strTemp = Mid$(strPath, InStrRev(strPath, &quot;\&quot;) + 1)
    FileNameNoExtension = Left$(strTemp, InStrRev(strTemp, &quot;.&quot;) - 1)
End Function

&#039; returns the filename with the extension from the file&#039;s full path
Function FileNameWithExtension(strPath As String) As String
    FileNameWithExtension = Mid$(strPath, InStrRev(strPath, &quot;\&quot;) + 1)
End Function

&#039; returns the filename without the extension from the file&#039;s full path
Function FileNameExtensionOnly(strPath As String) As String
    Dim strTemp As String
    strTemp = Mid$(strPath, InStrRev(strPath, &quot;\&quot;) + 1)
    FileNameExtensionOnly = Mid$(strTemp, InStrRev(strTemp, &quot;.&quot;) + 1)
End Function

&#039; returns the path only (i.e. the folder) from the file&#039;s full path
Function FilePath(strPath As String) As String
    FilePath = Left$(strPath, InStrRev(strPath, &quot;\&quot;))
End Function


&#039; Display a file dialog to select the target directory
&#039; Found this code in a google groups thread here:
&#039; http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/7187886c3c83a570/c278a2753e9e7ceb%23c278a2753e9e7ceb
&#039; or http://shrinkster.com/l0v
Public Function GetOutputDirectory() As String

    Dim retval As String &#039;Return Value

    Dim sMsg As String
    Dim cBits As Integer
    Dim xRoot As Integer

    Dim oShell As Object
    Set oShell = CreateObject(&quot;shell.application&quot;)

    sMsg = &quot;Select a Folder To Output The Attachments To&quot;
    cBits = 1
    xRoot = 17

    On Error Resume Next
        Dim oBFF
        Set oBFF = oShell.BrowseForFolder(0, sMsg, cBits, xRoot)
        If Err Then
            Err.Clear
            GetOutputDirectory = &quot;&quot;
            Exit Function
        End If
    On Error GoTo 0

    If Not IsObject(oBFF) Then
        retval = &quot;&quot;
    Else If Not (LCase(Left(Trim(TypeName(oBFF)), 6)) = &quot;folder&quot;) Then
        retval = &quot;&quot;
    Else
        retval = oBFF.self.path

        &#039; Make sure there&#039;s a trailing &quot;\&quot;
        If Right(retval, 1)  &quot;\&quot; Then
            retval = retval + &quot;\&quot;
        End If
    End If

    GetOutputDirectory = retval

End Function
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>The script opens up the message (and keeps them open) as it iterates over the messages and saves the attachments.  I edited the script so that it processes a subset of the messages at a time and this issue went away.  </p>
<p>I have attached the code below but am not sure how to format it correctly (so apologies for formatting of code).</p>
<pre>
Option Explicit

' Using code from:
' <a href="http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/" rel="nofollow">http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/</a>
'       <a href="http://arcanecode.files.wordpress.com/2007/01/saveattachments2.txt" rel="nofollow">http://arcanecode.files.wordpress.com/2007/01/saveattachments2.txt</a>
' <a href="http://www.rondebruin.nl/mail/folder2/saveatt.htm" rel="nofollow">http://www.rondebruin.nl/mail/folder2/saveatt.htm</a>
' <a href="http://www.vbaexpress.com/kb/getarticle.php?kb_id=767" rel="nofollow">http://www.vbaexpress.com/kb/getarticle.php?kb_id=767</a>


Public Sub SaveAttachments()

    ' Note, this assumes you are in the a folder with e-mail messages when you run it.
    ' It does not have to be the inbox, simply any folder with e-mail messages
    Dim attachmentCount As Integer
    Dim messageCount As Integer


    Dim outlookApp As New Outlook.Application
    Dim folder As Outlook.Explorer
    Set folder = outlookApp.ActiveExplorer


    Dim outputDir As String
    outputDir = GetOutputDirectory()
    If outputDir = "" Then
        MsgBox "You must pick a directory to save your files to. Exiting SaveAttachments.", vbCritical, "SaveAttachments"
        Exit Sub
    End If


    ' Loop thru each selected item in the inbox (100 at a time)
    Const stepSize = 100
    Dim currentIndex As Integer
    currentIndex = 1
    Do While currentIndex &lt; folder.Selection.Count
        Call ProcessChunk(folder.Selection, currentIndex, currentIndex + stepSize - 1, outputDir, attachmentCount, messageCount)
        currentIndex = currentIndex + stepSize
    Loop

    &#039; Clean up
    Set folder = Nothing
    Set outlookApp = Nothing

    &#039; Let user know we are done
    Dim doneMsg As String
    doneMsg = &quot;Completed saving &quot; + Format$(attachmentCount, &quot;#,0&quot;) + &quot; attachments in &quot; + Format$(messageCount, &quot;#,0&quot;) + &quot; Messages.&quot;
    MsgBox doneMsg, vbOKOnly, &quot;Save Attachments&quot;

    Exit Sub

ErrorHandler:

    Dim errMsg As String
    errMsg = &quot;An error has occurred. Error &quot; + Err.Number + &quot; &quot; + Err.Description
    Dim errResult As VbMsgBoxResult
    errResult = MsgBox(errMsg, vbAbortRetryIgnore, &quot;Error in Save Attachments&quot;)
    Select Case errResult
        Case vbAbort
            Exit Sub
        Case vbRetry
            Resume
        Case vbIgnore
            Resume Next
    End Select

End Sub


&#039; Process a &quot;chunk&quot; of the selected messages starting at startIndex and finishing at endIndex.
&#039; The attachments are saved in outputDir and the &#039;statistics&#039; parameters are modified (attachmentCount and messageCount)
Private Sub ProcessChunk(selection As Outlook.selection, _
            startIndex As Integer, endIndex As Integer, outputDir As String, _
            ByRef attachmentCount As Integer, ByRef messageCount As Integer)
    Dim outputFile As String
    Dim msgAttachement As Attachment

    Dim index As Integer
    For index = startIndex To endIndex
        If index &lt;= selection.Count Then
            messageCount = messageCount + 1

            For Each msgAttachement In selection.Item(index).Attachments

                If msgAttachement.Type  olOLE Then
                    outputFile = msgAttachement.filename
                    Dim uniqueFilename As String
                    uniqueFilename = GetUniqueFilename(outputDir, outputFile)
                    msgAttachement.SaveAsFile (outputDir + uniqueFilename)
                    attachmentCount = attachmentCount + 1
                End If
            Next msgAttachement
        End If
    Next index
End Sub


' If the filename already exists, add a counter to the filename (before the extension)
Public Function GetUniqueFilename(directory As String, filename As String) As String
    Dim uniqueFilename As String
    Dim index As Integer

    uniqueFilename = filename
    index = 1
    Do While Not Dir(directory + uniqueFilename) = vbNullString
        uniqueFilename = FileNameNoExtension(filename) + "_" + Format(index, "000") + "." + FileNameExtensionOnly(filename)
        index = index + 1
    Loop
    GetUniqueFilename = uniqueFilename
End Function


' returns the filename without the extension from the file's full path
Function FileNameNoExtension(strPath As String) As String
    Dim strTemp As String
    strTemp = Mid$(strPath, InStrRev(strPath, "\") + 1)
    FileNameNoExtension = Left$(strTemp, InStrRev(strTemp, ".") - 1)
End Function

' returns the filename with the extension from the file's full path
Function FileNameWithExtension(strPath As String) As String
    FileNameWithExtension = Mid$(strPath, InStrRev(strPath, "\") + 1)
End Function

' returns the filename without the extension from the file's full path
Function FileNameExtensionOnly(strPath As String) As String
    Dim strTemp As String
    strTemp = Mid$(strPath, InStrRev(strPath, "\") + 1)
    FileNameExtensionOnly = Mid$(strTemp, InStrRev(strTemp, ".") + 1)
End Function

' returns the path only (i.e. the folder) from the file's full path
Function FilePath(strPath As String) As String
    FilePath = Left$(strPath, InStrRev(strPath, "\"))
End Function


' Display a file dialog to select the target directory
' Found this code in a google groups thread here:
' <a href="http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/7187886c3c83a570/c278a2753e9e7ceb%23c278a2753e9e7ceb" rel="nofollow">http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/7187886c3c83a570/c278a2753e9e7ceb%23c278a2753e9e7ceb</a>
' or <a href="http://shrinkster.com/l0v" rel="nofollow">http://shrinkster.com/l0v</a>
Public Function GetOutputDirectory() As String

    Dim retval As String 'Return Value

    Dim sMsg As String
    Dim cBits As Integer
    Dim xRoot As Integer

    Dim oShell As Object
    Set oShell = CreateObject("shell.application")

    sMsg = "Select a Folder To Output The Attachments To"
    cBits = 1
    xRoot = 17

    On Error Resume Next
        Dim oBFF
        Set oBFF = oShell.BrowseForFolder(0, sMsg, cBits, xRoot)
        If Err Then
            Err.Clear
            GetOutputDirectory = ""
            Exit Function
        End If
    On Error GoTo 0

    If Not IsObject(oBFF) Then
        retval = ""
    Else If Not (LCase(Left(Trim(TypeName(oBFF)), 6)) = "folder") Then
        retval = ""
    Else
        retval = oBFF.self.path

        ' Make sure there's a trailing "\"
        If Right(retval, 1)  "\" Then
            retval = retval + "\"
        End If
    End If

    GetOutputDirectory = retval

End Function
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27983</link>
		<dc:creator><![CDATA[Josh]]></dc:creator>
		<pubDate>Thu, 16 Sep 2010 13:29:17 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27983</guid>
		<description><![CDATA[I added this function to get a unique filename:

&#039; If the filename already exists, add a counter to the filename (before the extension)
Public Function GetUniqueFilename(directory As String, filename As String) As String
    Dim uniqueFilename As String
    Dim index As Integer

    uniqueFilename = filename
    index = 1
    Do While Not Dir(directory + uniqueFilename) = vbNullString
        uniqueFilename = FileNameNoExtension(filename) + &quot;_&quot; + Format(index, &quot;000&quot;) + &quot;.&quot; + FileNameExtensionOnly(filename)
        index = index + 1
    Loop
    GetUniqueFilename = uniqueFilename
End Function]]></description>
		<content:encoded><![CDATA[<p>I added this function to get a unique filename:</p>
<p>&#8216; If the filename already exists, add a counter to the filename (before the extension)<br />
Public Function GetUniqueFilename(directory As String, filename As String) As String<br />
    Dim uniqueFilename As String<br />
    Dim index As Integer</p>
<p>    uniqueFilename = filename<br />
    index = 1<br />
    Do While Not Dir(directory + uniqueFilename) = vbNullString<br />
        uniqueFilename = FileNameNoExtension(filename) + &#8220;_&#8221; + Format(index, &#8220;000&#8243;) + &#8220;.&#8221; + FileNameExtensionOnly(filename)<br />
        index = index + 1<br />
    Loop<br />
    GetUniqueFilename = uniqueFilename<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MikeA</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27981</link>
		<dc:creator><![CDATA[MikeA]]></dc:creator>
		<pubDate>Wed, 15 Sep 2010 00:35:34 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27981</guid>
		<description><![CDATA[Jeremy,

Would you mind posting up the code that you altered to append a 1, 2, 3, etc... to the end of the filenames? I am also trying to find a way to append sequential numbers to the end of the filenames, as I may have thousands of attachments to save...!

But indeed, a great macro all up.

Cheers :)]]></description>
		<content:encoded><![CDATA[<p>Jeremy,</p>
<p>Would you mind posting up the code that you altered to append a 1, 2, 3, etc&#8230; to the end of the filenames? I am also trying to find a way to append sequential numbers to the end of the filenames, as I may have thousands of attachments to save&#8230;!</p>
<p>But indeed, a great macro all up.</p>
<p>Cheers <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27979</link>
		<dc:creator><![CDATA[Jeremy]]></dc:creator>
		<pubDate>Mon, 13 Sep 2010 19:54:57 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27979</guid>
		<description><![CDATA[Maybe I&#039;m not crazy, after all.  :)

Tested the original macro with 100+ messages and it stopped/crashed after the 100th message/attachment.  Any idea what it could be?

Thanks again!  :)]]></description>
		<content:encoded><![CDATA[<p>Maybe I&#8217;m not crazy, after all.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Tested the original macro with 100+ messages and it stopped/crashed after the 100th message/attachment.  Any idea what it could be?</p>
<p>Thanks again!  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy</title>
		<link>http://arcanecode.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27978</link>
		<dc:creator><![CDATA[Jeremy]]></dc:creator>
		<pubDate>Mon, 13 Sep 2010 14:09:50 +0000</pubDate>
		<guid isPermaLink="false">http://arcanecode.wordpress.com/2007/01/03/enhancing-the-save-attachments-outlook-macro/#comment-27978</guid>
		<description><![CDATA[Love this macro!  I scan a lot of docs to PDF in bulk (receipts, bills, etc) and love being able to extract them all so quickly and efficiently. 

My prob is that when I scan a ton of documents at once, they all have the same name (i.e. &quot;scan.pdf&quot;) and having to rename each of them manually is time-consuming even with the input box.  I tried to play around with the macro to automatically number each document based on the message number and it worked (i.e. &quot;scan1.pdf&quot;, &quot;scan2.pdf&quot;, etc) but it keeps crashing at 100.  Ugh.  I tried to troubleshoot as best as I could but haven&#039;t nailed it yet.

REQUEST: any chance of a version of this that would do exactly that - i.e. rather than manually renaming, check for a document with the same filename and then just append the next in a sequential list of numbers to the document filename?

Regardless, great macro! Thanks!  :)]]></description>
		<content:encoded><![CDATA[<p>Love this macro!  I scan a lot of docs to PDF in bulk (receipts, bills, etc) and love being able to extract them all so quickly and efficiently. </p>
<p>My prob is that when I scan a ton of documents at once, they all have the same name (i.e. &#8220;scan.pdf&#8221;) and having to rename each of them manually is time-consuming even with the input box.  I tried to play around with the macro to automatically number each document based on the message number and it worked (i.e. &#8220;scan1.pdf&#8221;, &#8220;scan2.pdf&#8221;, etc) but it keeps crashing at 100.  Ugh.  I tried to troubleshoot as best as I could but haven&#8217;t nailed it yet.</p>
<p>REQUEST: any chance of a version of this that would do exactly that &#8211; i.e. rather than manually renaming, check for a document with the same filename and then just append the next in a sequential list of numbers to the document filename?</p>
<p>Regardless, great macro! Thanks!  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

