PC Review


Reply
Thread Tools Rate Thread

Attachment delete method

 
 
=?Utf-8?B?Q2F0YWxpbg==?=
Guest
Posts: n/a
 
      23rd Sep 2005
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
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      23rd Sep 2005
Take a look at the code sample at
http://www.slovaktech.com/code_sampl...ripAttachments. It might help
you.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Catalin" <(E-Mail Removed)> wrote in message
news:3B372CEE-46EC-41B1-BDFB-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Michael Bednarek
Guest
Posts: n/a
 
      23rd Sep 2005
On Fri, 23 Sep 2005 04:09:03 -0700, "Catalin"
<(E-Mail Removed)> wrote in
microsoft.public.outlook.program_vba:

>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

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
 
Reply With Quote
 
=?Utf-8?B?Q2F0YWxpbg==?=
Guest
Posts: n/a
 
      26th Sep 2005
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" wrote:

> On Fri, 23 Sep 2005 04:09:03 -0700, "Catalin"
> <(E-Mail Removed)> wrote in
> microsoft.public.outlook.program_vba:
>
> >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
>
> --
> Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      26th Sep 2005
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Catalin" <(E-Mail Removed)> wrote in message
news:FAD132CD-F14E-4D43-80F1-(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When you delete an email in Outlook, is the attachment also delete Sinclair Microsoft Outlook Discussion 3 24th Feb 2009 08:53 PM
attachment in email as parameter to method call Ludwig Microsoft C# .NET 4 15th May 2007 01:37 PM
Difference between Delete method and RemoveRow method CW Microsoft ASP .NET 0 1st Apr 2004 02:07 AM
Attachment.SaveasFile Method: How to Check if Success ? Terry Coccoli Microsoft Outlook VBA Programming 1 29th Mar 2004 05:34 PM
Attachment.SaveAsFile Method Richard Winston Microsoft Outlook VBA Programming 1 12th Dec 2003 10:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:43 PM.