?
Solved

Save Outlook attachments to the hard drive

Posted on 2007-04-04
2
Medium Priority
?
289 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:
K V earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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 …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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