Attachment delete method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everybody,

I use OL 2003 and I use the following code to save the incoming mail
attachments (based on a rule of the sender name and subject) on a specific
folder in My Documents, delete the attachments and clear the space:

strControl = subsubfolder.Items.Count
Set olMail = subsubfolder.Items(strControl) ' to get the last
mailItem moved in the folder by the rule

For Each atm In olMail.Attachments
atm.SaveAsFile "C:\Documents and Settings\..." & atm.FileName
Next

For Each atm In olMail.Attachments
atm.Delete
Next

The problem is that the attachments are not deleted.
I am a newbie with VBA. Can somebody help me please ?

Also, is there any other method which returns the last mailItem received in
a specific folder? How can I use AddItem method in the rule?

Thanks in advance,
Catalin
 
I use OL 2003 and I use the following code to save the incoming mail
attachments (based on a rule of the sender name and subject) on a specific
folder in My Documents, delete the attachments and clear the space:

strControl = subsubfolder.Items.Count
Set olMail = subsubfolder.Items(strControl) ' to get the last
mailItem moved in the folder by the rule

For Each atm In olMail.Attachments
atm.SaveAsFile "C:\Documents and Settings\..." & atm.FileName
Next

For Each atm In olMail.Attachments
atm.Delete
Next

The problem is that the attachments are not deleted.
I am a newbie with VBA. Can somebody help me please ?
[snip]

From memory, try adding this:
olMail.Save
 
Thank you very much Michael and Ken. You have been very helpful.

Well, can you also tell me how I can refer to the last mailItem received in
a folder using AddItem ? is there any way to do that?

Thanks,
Catalin

Michael Bednarek said:
I use OL 2003 and I use the following code to save the incoming mail
attachments (based on a rule of the sender name and subject) on a specific
folder in My Documents, delete the attachments and clear the space:

strControl = subsubfolder.Items.Count
Set olMail = subsubfolder.Items(strControl) ' to get the last
mailItem moved in the folder by the rule

For Each atm In olMail.Attachments
atm.SaveAsFile "C:\Documents and Settings\..." & atm.FileName
Next

For Each atm In olMail.Attachments
atm.Delete
Next

The problem is that the attachments are not deleted.
I am a newbie with VBA. Can somebody help me please ?
[snip]

From memory, try adding this:
olMail.Save
 
You'd have to sort the Items collection for that folder by date, then you
could easily pick out the first or last items in the folder.
 
Back
Top