Solved

Save Outlook attachments to the hard drive

Posted on 2007-04-04
2
279 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
[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 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 70

Expert Comment

by:Éric Moreau
ID: 18856602
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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