Solved

Save Outlook attachments to the hard drive

Posted on 2007-04-04
2
256 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 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

16 Experts available now in Live!

Get 1:1 Help Now