Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / July 2003

Tip: Looking for answers? Try searching our database.

Blank subject / to / sender  fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Colin - 29 Jul 2003 16:00 GMT
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
> ******************************************************
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.