View Single Post
  #1  
Old August 25th 07, 12:31 AM posted to microsoft.public.outlook.program_vba
adimax@gmail.com
external usenet poster
 
Posts: 22
Default Delete based on Attachment Size (Item.Size)...

Alright, I'm pretty happy with my code so far. Its setup as a rule and
when emails with attachments come in, the user is prompted with a save
box, they type a filename in (or Cancel, either way) and everything
works as planned.

However, some of the emails are in error and the attachments of these
emails are always 2k or less. So, now I'm trying to code that part in.
A snippet of my code:


'Process the selected item
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection

'Start Process
For Each myItem In myOlSel

'Attachments
Set myAttachments = myItem.Attachments

'Check
If myAttachments.Count 0 Then

'Do the following
For i = 1 To myAttachments.Count

StartPrompt:

myFin = InputBox("Please type a filename below. You do not have to
include the .wav extension:", "Saving recording...", "")

If myFin = "" Then

myItem.UnRead = True
myItem.Move myDestFolder2

Exit Sub
End If

'Save to destionation folder
myAttachments(i).SaveAsFile myOrt & _
myFin & ".wav"

myItem.UnRead = False
myItem.Move myDestFolder1

Next i

End If

If I were to add the following code :

If myAttachments(i).Item.Size 2048 Then
myItem.Delete
End If

right before the StartPrompt, would that take care of any 2k or less
files for me before they even get the popup box?

Thanks as always!

Ads
 

Consolidate Debt - Ogłoszenia,praca - Jorge Bucay - Mortgage Calculator - Charity