Removal of attachments on email items in Sent items folder 
Author Message
 Removal of attachments on email items in Sent items folder

Hi,

I am new to Outlook VBA...or any VBA.
I'm working on a macro that will permanently delete all attachments from a
"Sents items" folder.
Here is what I came-up with:
______________________________
Sub a()
compte = 0
counter = 0
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderSentMail)
Set mynewfolder = myFolder.Folders("Test")
compte = mynewfolder.Items.Count + 1

 Do While counter < compte    ' Inner loop.
 counter = counter + 1
 Set myItem = mynewfolder.Items(counter)
 Set myAttachments = myItem.Attachments
       While myAttachments.Count > 0
       myAttachments.Remove 1
       Wend
  Loop

End Sub

_______________________-

It has a couple of flaws, but it works;as long as it is running....
I stepped through-it, and the attachments do disappear, but when the macro
is ended, all the attachment re-appear !

How can I fix this ?

Thanks in advance.

Francois Phaneuf



Sun, 11 May 2003 03:00:00 GMT  
 Removal of attachments on email items in Sent items folder
You're missing any statement to save the item after you remove its
attachments. FYI, you can use a For Each ... Next loop for the items in the
folder, just not for the attachments.

--
Sue Mosher
Author of
  "Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours"
  "Microsoft Outlook 2000 E-mail and Fax Guide"

Outlook and Exchange solutions at http://www.slipstick.com


Quote:
> Hi,

> I am new to Outlook VBA...or any VBA.
> I'm working on a macro that will permanently delete all attachments from a
> "Sents items" folder.
> Here is what I came-up with:
> ______________________________
> Sub a()
> compte = 0
> counter = 0
> Set myOlApp = CreateObject("Outlook.Application")
> Set myNameSpace = myOlApp.GetNamespace("MAPI")
> Set myFolder = myNameSpace.GetDefaultFolder(olFolderSentMail)
> Set mynewfolder = myFolder.Folders("Test")
> compte = mynewfolder.Items.Count + 1

>  Do While counter < compte    ' Inner loop.
>  counter = counter + 1
>  Set myItem = mynewfolder.Items(counter)
>  Set myAttachments = myItem.Attachments
>        While myAttachments.Count > 0
>        myAttachments.Remove 1
>        Wend
>   Loop

> End Sub

> _______________________-

> It has a couple of flaws, but it works;as long as it is running....
> I stepped through-it, and the attachments do disappear, but when the macro
> is ended, all the attachment re-appear !

> How can I fix this ?

> Thanks in advance.

> Francois Phaneuf



Sun, 11 May 2003 03:00:00 GMT  
 Removal of attachments on email items in Sent items folder
Thanks Sue,

I already tried "myItem.save" with no error but no save was performed.
It seems I am missing someting else.
I have been looking that matter with some programmers; no luck yet !
Should I consider replacing my programmers ??????

No kidding, do you have more details to save my items ?

Thanks in advance

Francois Phaneuf



Quote:
> You're missing any statement to save the item after you remove its
> attachments. FYI, you can use a For Each ... Next loop for the items in
the
> folder, just not for the attachments.

> --
> Sue Mosher
> Author of
>   "Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours"
>   "Microsoft Outlook 2000 E-mail and Fax Guide"

> Outlook and Exchange solutions at http://www.slipstick.com



> > Hi,

> > I am new to Outlook VBA...or any VBA.
> > I'm working on a macro that will permanently delete all attachments from
a
> > "Sents items" folder.
> > Here is what I came-up with:
> > ______________________________
> > Sub a()
> > compte = 0
> > counter = 0
> > Set myOlApp = CreateObject("Outlook.Application")
> > Set myNameSpace = myOlApp.GetNamespace("MAPI")
> > Set myFolder = myNameSpace.GetDefaultFolder(olFolderSentMail)
> > Set mynewfolder = myFolder.Folders("Test")
> > compte = mynewfolder.Items.Count + 1

> >  Do While counter < compte    ' Inner loop.
> >  counter = counter + 1
> >  Set myItem = mynewfolder.Items(counter)
> >  Set myAttachments = myItem.Attachments
> >        While myAttachments.Count > 0
> >        myAttachments.Remove 1
> >        Wend
> >   Loop

> > End Sub

> > _______________________-

> > It has a couple of flaws, but it works;as long as it is running....
> > I stepped through-it, and the attachments do disappear, but when the
macro
> > is ended, all the attachment re-appear !

> > How can I fix this ?

> > Thanks in advance.

> > Francois Phaneuf



Wed, 14 May 2003 04:11:31 GMT  
 Removal of attachments on email items in Sent items folder

You must have a myItem.Save statement somewhere to save your changes. Where
did you put it?

Did you try using a For Each ... Next loop, as I suggested?

--
Sue Mosher
Author of
  "Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours"
  "Microsoft Outlook 2000 E-mail and Fax Guide"

Outlook and Exchange solutions at http://www.slipstick.com


Quote:
> Thanks Sue,

> I already tried "myItem.save" with no error but no save was performed.
> It seems I am missing someting else.
> I have been looking that matter with some programmers; no luck yet !
> Should I consider replacing my programmers ??????

> No kidding, do you have more details to save my items ?

> Thanks in advance

> Francois Phaneuf



> > > Hi,

> > > I am new to Outlook VBA...or any VBA.
> > > I'm working on a macro that will permanently delete all attachments
from
> a
> > > "Sents items" folder.
> > > Here is what I came-up with:
> > > ______________________________
> > > Sub a()
> > > compte = 0
> > > counter = 0
> > > Set myOlApp = CreateObject("Outlook.Application")
> > > Set myNameSpace = myOlApp.GetNamespace("MAPI")
> > > Set myFolder = myNameSpace.GetDefaultFolder(olFolderSentMail)
> > > Set mynewfolder = myFolder.Folders("Test")
> > > compte = mynewfolder.Items.Count + 1

> > >  Do While counter < compte    ' Inner loop.
> > >  counter = counter + 1
> > >  Set myItem = mynewfolder.Items(counter)
> > >  Set myAttachments = myItem.Attachments
> > >        While myAttachments.Count > 0
> > >        myAttachments.Remove 1
> > >        Wend
> > >   Loop

> > > End Sub

> > > _______________________-

> > > It has a couple of flaws, but it works;as long as it is running....
> > > I stepped through-it, and the attachments do disappear, but when the
> macro
> > > is ended, all the attachment re-appear !

> > > How can I fix this ?

> > > Thanks in advance.

> > > Francois Phaneuf



Wed, 14 May 2003 04:48:44 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Programmatically delete an item from the Sent Items Folder

2. Howto trap MAPIFolder.Items.ItemAdd on Sent Items Folder

3. Saving Item.body and item.attachment

4. Add attachment from item in folder to MailItem

5. automate delete attachment in sent items?

6. Detecting an item move to Deleted Items folder

7. Explorer-like interface to Outlook items with mixed type items in a folder

8. Programmatically delete an item from the Sent items

9. How to delete selective items from Sent Items from PF Script

10. Meeting item when sent as item gives problems

11. Copy viewed items from one folder into email body

12. interating through the "Sent Items" Folder

 

 
Powered by phpBB® Forum Software