Solved

Save Outlook attachments to the hard drive

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
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…

729 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