I have found the following code that runs as a macro to
delete all mail that has a blank subject, or to or sender
field (i.e. SPAM).
My problem is, that when the deletion routine activates
(ObjInboxItems_ItemAdd) I get an outlook popup telling me
that a program is attempting to access incoming mail do I
want to allow this access.
Do any of you know of a better way of doing this.
Obviously I cant use the Rules wizard to set up new rules
as it wont accept blank inputs.
The code follows
******************************************************
' Run this code to start your rule.
Sub StartRule()
Dim objNameSpace As Outlook.NameSpace
Dim objInboxFolder As Outlook.MAPIFolder
Set objNameSpace = Application.Session
Set objInboxFolder = objNameSpace.GetDefaultFolder
(olFolderInbox)
Set objInboxItems = objInboxFolder.Items
End Sub
' Run this code to stop your rule.
Sub StopRule()
Set objInboxItems = Nothing
End Sub
' This code is the actual rule.
Private Sub objInboxItems_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
If Item.To = "" Or Item.SenderName = "" Or
Item.Subject = "" Then
Item.Categories = "Suspected Junk"
Item.Save
Item.Delete
End If
End If
End Sub
******************************************************
Ken Slovak - [MVP - Outlook] - 30 Jul 2003 15:29 GMT
Item.SenderName is the problem. If you eliminate that you'd eliminate
the prompts. Other than that your options are listed at
http://64.78.15.8/outlook/esecup.htm#autosec
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
> I have found the following code that runs as a macro to
> delete all mail that has a blank subject, or to or sender
[quoted text clipped - 58 lines]
> End Sub
> ******************************************************