J
Jeff Miller
I get hundreds of emails a day on the webmaster account
that have their attachments blocked from Exchange. They
all have "Replaced * File.txt" attachments where * could
be Infected/Blocked (I'm not aware of any others.) I saw
some examples on the web for writing VBA with custom rules.
Here's what I wrote:
'---------------------------------------------------
Sub FilterJunk(objItem As MailItem)
If objItem.Attachments.Count > 0 Then
deleteMail = False
Set regEx = CreateObject("VBScript.RegExp")
regEx.Global = False
regEx.IgnoreCase = True
regEx.Pattern = "^Replaced \w+ File.txt"
For Each objAttach In objItem.Attachments
If regEx.Test(objAttach.FileName) Then
deleteMail = True
Exit For
End If
Next
Set regEx = Nothing
If deleteMail Then Call objItem.Delete
End If
Set objItem = Nothing
End Sub
'---------------------------------------------------
I can't see any problems based upon the code examples I've
seen out there. This should work. However, nothing happens
when I set up the rules wizard to run this code on my
local machine (no errors, nothing.)
So, I tried a simple test:
'---------------------------------------------------
Sub DoSomething(item As Object)
MsgBox "Something happened..."
End Sub
'---------------------------------------------------
Still, nothing.
My other rules work just fine (they just move mail to
various folders based upon e-mail addresses/subject
lines... nothing fancy requiring VBA.) Any help with this
problem would be appreciated.
~Jeff
that have their attachments blocked from Exchange. They
all have "Replaced * File.txt" attachments where * could
be Infected/Blocked (I'm not aware of any others.) I saw
some examples on the web for writing VBA with custom rules.
Here's what I wrote:
'---------------------------------------------------
Sub FilterJunk(objItem As MailItem)
If objItem.Attachments.Count > 0 Then
deleteMail = False
Set regEx = CreateObject("VBScript.RegExp")
regEx.Global = False
regEx.IgnoreCase = True
regEx.Pattern = "^Replaced \w+ File.txt"
For Each objAttach In objItem.Attachments
If regEx.Test(objAttach.FileName) Then
deleteMail = True
Exit For
End If
Next
Set regEx = Nothing
If deleteMail Then Call objItem.Delete
End If
Set objItem = Nothing
End Sub
'---------------------------------------------------
I can't see any problems based upon the code examples I've
seen out there. This should work. However, nothing happens
when I set up the rules wizard to run this code on my
local machine (no errors, nothing.)
So, I tried a simple test:
'---------------------------------------------------
Sub DoSomething(item As Object)
MsgBox "Something happened..."
End Sub
'---------------------------------------------------
Still, nothing.
My other rules work just fine (they just move mail to
various folders based upon e-mail addresses/subject
lines... nothing fancy requiring VBA.) Any help with this
problem would be appreciated.
~Jeff