Re: Saving Attachments
From: Sue Mosher [MVP-Outlook] (suemvp_at_outlookcode.com)
Date: 06/28/04
- Next message: Carlos Lozano: "Re: Outlook & VBA: Problem filtering a View XML"
- Previous message: Sue Mosher [MVP-Outlook]: "Re: Outlook & VBA: Problem filtering a View XML"
- In reply to: Andi Plotsky: "Saving Attachments"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 28 Jun 2004 08:53:35 -0400
1) Your code below depends on an ActiveInspector window being available,
i.e. a window displaying an individual item. If you want it to work also
when you have selected an item in a folder, you need to work with
ActiveExplorer.Selection. See
http://www.outlookcode.com/codedetail.aspx?id=50 for a GetCurrentItem()
function that handles either, depending on which window is active.
2) Yes, you would need to loop through the Attachments collection to save
each Attachment as a file.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Andi Plotsky" <irisinfo@bellsouth.net> wrote in message
news:g6kDc.1585$pr2.574@bignews1.bellsouth.net...
>
> 1) I'm trying to save 5 attachments from 1 e-mail. If I run it with the
> message closed, but highlighted, I get a "Object variable or With block
> not Set" error. The Debugger sends me to the Set myItem line. The code
I
> used is shown below. ( Path= C:\My Documents\test). If I open the message
> and run it, I don't get the error, it runs through the entire routine, but
> the file hasn't really been saved. What am I doing wrong?
>
> 2) When I'm ready to go for additional attachments do I need to loop
through
> them, or just repeat the SaveAsFile statement below with the proper index?
>
> Sub SaveAttachments()
> Dim myOlApp As Object
> Dim myItem As Outlook.MailItem
> Dim myAttachments As Attachments
>
> Set myOlApp = CreateObject("Outlook.Application")
> Set myItem = myOlApp.ActiveInspector.CurrentItem
> Set myAttachments = myItem.Attachments
> myAttachments.Item(1).SaveAsFile "C:\My Documents\test" & _
> myAttachments.Item(1).DisplayName
> MsgBox "File Saved"
> End Sub
- Next message: Carlos Lozano: "Re: Outlook & VBA: Problem filtering a View XML"
- Previous message: Sue Mosher [MVP-Outlook]: "Re: Outlook & VBA: Problem filtering a View XML"
- In reply to: Andi Plotsky: "Saving Attachments"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|