Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / May 2008

Tip: Looking for answers? Try searching our database.

Delete Attachments - Just Shy of Solution

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Access101 - 22 May 2008 18:10 GMT
I select 3 emails, all of which have attachments.  The code loops through and
sees all 3 emails, but only removes attachments from the 1st one.  Any help
is appreciated.

   Dim objOutlook As Outlook.Application
   Dim objMsg As Object
   Dim objAttachments As Outlook.Attachments
   Dim objSelectedItems As Outlook.Selection
   Dim i As Long, lngCounter As Long
   
   Set objOutlook = CreateObject("Outlook.Application")
   Set objSelectedItems = objOutlook.ActiveExplorer.Selection
   
   For Each objMsg In objSelectedItems
   
       If objMsg.Class = olMail Then
       
           Set objAttachments = objMsg.Attachments
           lngCounter = objAttachments.Count
       
           If lngCounter > 0 Then
               
               For i = lngCounter To 1 Step -1
                   objAttachments.Item(i).Delete
               Next i
           
           End If
       End If
       
   Next
Michael Bauer [MVP - Outlook] - 22 May 2008 18:36 GMT
Call objMsg.Save after deleting all oof its attachments.

Signature

Best regards
Michael Bauer - MVP Outlook

 : Outlook Categories? Category Manager Is Your Tool:
 : <http://www.vboffice.net/product.html?pub=6&lang=en>

Am Thu, 22 May 2008 10:10:01 -0700 schrieb Access101:

> I select 3 emails, all of which have attachments.  The code loops through and
> sees all 3 emails, but only removes attachments from the 1st one.  Any help
[quoted text clipped - 26 lines]
>        
>     Next
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.