Solved

Save Outlook attachments to the hard drive

Posted on 2007-04-04
2
246 Views
Last Modified: 2012-06-22
I am looking to try and find some sample code that will run through an Outlook 2003 Inbox and remove all attachments and store them on the hard drive.  I have found a few examples out on a few sites and they all seem to not work exactly as stated.

Thanks in advance.

-M
0
Comment
Question by:MELeBlanc
2 Comments
 
LVL 21

Accepted Solution

by:
theGhost_k8 earned 500 total points
ID: 18855528
what you can do is select the inbox folder by

   Set nspNameSpace = Application.GetNamespace("MAPI")
   Set objMail = nspNameSpace.GetDefaultFolder(olFolderInbox)

then using looping you can iterate for #of mails count, i think its objMail.items.count
and for each mailItem you can check for the attachments by,


If myMail.Item.Attachments.Count > 0 Then      
      For i = 1 To myMail.Item.Attachments.Count
            myMail.Item.Attachments.Item(i).SaveAsFile(outlookAttPath & "\" & System.IO.Path.GetFileNameWithoutExtension(myMail.Item.Attachments.Item(i).FileName) & "-" & dateTimeStamp &  System.IO.Path.GetExtension((myMail.Item.Attachments.Item(i).FileName)))
                Next
End If

again you want to delete the attachment, i dont know if it possible in any oulook except 2007.
but you can give a try by calling a Delete method by,
                myMail.Item.Attachments.Item(i).delete

the other sources you should refer:

http://www.fontstuff.com/outlook/oltut01.htm
http://www.outlookcode.com/codedetail.aspx?id=70
http://www.slovaktech.com/code_samples.htm#StripAttachments
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 18856602
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now