?
Solved

outlook 2000 macro, saving attachments

Posted on 2003-03-04
3
Medium Priority
?
158 Views
Last Modified: 2010-05-01
I want to be able to save the attachments of an email to a default locations, thru one button.

Ive got some code to loop thru all the emails in my inbox, and save (See below) but this isnt what im after.  I need to save just the highlighted on, or be able to choose one.  Ie, get rid of the "For Each oMailItem In oFolder.Items" and change it to a single item.


Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
Set oMailItem = oFolder.Items

For Each oMailItem In oFolder.Items
    With oMailItem
        If oMailItem.Attachments.Count > 0 Then
            oMailItem.Attachments.Item(1).SaveAsFile 'Dir1.Path & "\" & oMailItem.Attachments.Item(1).Parent & "~~" & oMailItem.Attachments.Item(1).FileName
            DoEvents
           
        End If
    End With
Next oMailItem

Set oMailItem = Nothing
Set oFolder = Nothing
Set oNameSpace = Nothing
Set oApp = Nothing
0
Comment
Question by:calfboy
[X]
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
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
jjardine earned 400 total points
ID: 8064022
you might look at something like this

Count = oApp.ActiveExplorer.Selection.Count
If Count > 0 Then
   For Index = 1 To Count
      do your saving of attachments
      it is recommended to make sure it is of class=olMail
   Next index
End If

Good luck
0
 

Author Comment

by:calfboy
ID: 8064252
it is recommended to make sure it is of class=olMail

How do I do that? ^^
0
 

Author Comment

by:calfboy
ID: 8064274
I changed my code to be like this,

For Each oMailItem In oApp.ActiveExplorer.Selection
    If oMailItem.Attachments.Count > 0 Then
        oMailItem.Attachments.Item(1).SaveAsFile "c:\" & oMailItem.Attachments.Item(1).FileName
    End If
Next

Now, ill add a loop for each attachment. (Incase there is more then one.)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month11 days, 8 hours left to enroll

752 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