Advertisement

09.29.2008 at 10:12AM PDT, ID: 23772115 | Points: 350
[x]
Attachment Details

saving attachments in bulk

Asked by NO_CARRIER in Outlook Groupware Software, Microsoft Applications

Tags: , ,

I need help debugging some code.  I've been using the following code (kindly provided by BlueDevilFan) a while back

The way it works (or should work) is:
1) highlight all emails in inbox
2) when the macro runs, it will search for e-mails with attachments
3) it will then search the body of the e-mail for any lines beginning with an asterisk (*)  These are the filenames to save each attachment as.
4) It will recursively save each attachment with however many filenames are provided in the body of the e-mail.


The problem is, lately we have been recieving a lot of attachments with the same filename.  Say I highlight 600 e-mail messages, all with attachments.  Around 100 of those will have the same attachment filename. (MyFile001.pdf), although the filenames provided in the body of the e-mail for each attachment is different.

After processing around 30 or so of these e-mails with the same attachment name, the macro poops out with the following error message:

Cannot save the attachment. Can't create file: MyFile001.PDF. Right-click the folder you want to create the file in, and then click Properties on the shortcut menu to check your permissions for the folder.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
Sub SaveAttachments()
    Dim olkSelectedItems As Object, _
        olkItem As Object, _
        objFile As Object, _
        objDict As Object, _
        strFilename As String, _
        arrLines As Variant, _
        varName As Variant, _
        varTemp As Variant
    strFilename = ""
    Set olkSelectedItems = Application.ActiveExplorer.Selection
    For Each olkItem In olkSelectedItems
        Set objDict = CreateObject("Scripting.Dictionary")
        If olkItem.Attachments.Count > 0 Then
            arrLines = Split(olkItem.Body, vbCrLf)
            For Each varName In arrLines
                varTemp = Trim(varName)
                If Left(varTemp, 1) = "*" Then
                    If Not objDict.Exists(varTemp) Then
                        objDict.Add Mid(varTemp, 2), Mid(varTemp, 2)
                    End If
                End If
            Next
            arrLines = objDict.Items()
            For Each objFile In olkItem.Attachments
                For Each varName In arrLines
                    strFilename = "c:\OutlookTemp\" & varName
                    objFile.SaveAsFile strFilename
                Next
            Next
        End If
    Next
    Set objDict = Nothing
    Set objFile = Nothing
    Set olkItem = Nothing
    Set olkSelectedItems = Nothing
End Sub
[+][-]09.29.2008 at 10:41AM PDT, ID: 22598679

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 01:00PM PDT, ID: 22600050

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 01:23PM PDT, ID: 22600276

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 06:39AM PDT, ID: 22605220

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 07:10AM PDT, ID: 22605504

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 12:49PM PDT, ID: 22608768

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 01:06PM PDT, ID: 22608941

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 01:12PM PDT, ID: 22609001

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 01:14PM PDT, ID: 22609016

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.30.2008 at 01:23PM PDT, ID: 22609106

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 06:58AM PDT, ID: 22678407

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.09.2008 at 12:06PM PDT, ID: 22681412

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.28.2008 at 10:01AM PDT, ID: 22823838

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.28.2008 at 10:30AM PDT, ID: 22824123

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628