Solved

how can I block all emails with html content

Posted on 2002-05-27
10
153 Views
Last Modified: 2010-04-08
I want to filter out all msgs that I receive in outlook 2000 that have html as the body, as these are invariably junk.
ie. Any msgs that are ordainary text, allow into inbox
    any msgs with html as the body text, move to junk folder

Any ideas on how I might do this?

Cheers
Duncan
0
Comment
Question by:blarts
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 7037449
I would probably go with a VBA macro/event sink that checks the length of the htmlbody propery and then moves the item.

For an example on how to convert a message from html to plain text can be found at http://www.slipstick.com/dev/code/zaphtml.htm (note: with a little modification of this code, it will solve the first paragraph.)
0
 
LVL 23

Expert Comment

by:slink9
ID: 7038949
If you are not interested in vba coding, you can go third-party.  Pop Agent sounds like an interesting alternative for email purposes - http://www.imesoftware.com/popagent.htm
0
 

Author Comment

by:blarts
ID: 7043919
The VBA option sounds good, however I don't know how to set about doing this as my programming skills are on mainframes (old dinosaur that I am)
Any chance of an idiots step by step guide to inplementing a suitable macro?
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 7046214
Sure... this code is a bit weird because outlook isn't allowing me to move the original item.  so this code makes a copy and moves it to a folder named Junk Mail right under the inbox and then deletes the original.

steps for you...
* Press CTRL+F11
* Go to ThisOutlookSession and paste in the following


Option Explicit
Private WithEvents olInboxItems As Items

Private Sub Application_Startup()

  Dim objNS As NameSpace
  Set objNS = Application.GetNamespace("MAPI")
  ' instantiate objects declared WithEvents
  Set olInboxItems = _
    objNS.GetDefaultFolder(olFolderInbox).Items
  Set objNS = Nothing
End Sub

Private Sub Application_Quit()
  ' disassociate global objects declared WithEvents
  Set olInboxItems = Nothing
End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
  Dim objFolder As Outlook.MAPIFolder
  Dim objTemp As Object
  ' On Error Resume Next

  If Item.HTMLBody <> vbNullString Then
    Set objFolder = _
      Application.Session.GetDefaultFolder(olFolderInbox)

    Set objFolder = objFolder.Folders.Item("Junk Mail")
    Set objTemp = Item.Copy
    Call objTemp.Move(objFolder)
    objTemp.Close (olSave)
    Item.Delete
  End If
  Set Item = Nothing
End Sub



0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 7046218
I should mention this... this method can end up missing items to copy/delete.  there is a timing issue in outlook where it won't call the event for every message. so if you end up getting 20 or more items at once, expect the code to miss a few.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 1

Accepted Solution

by:
tcav earned 500 total points
ID: 7056078
I already have a Rules Wizard rule that does just mhat you're looking for.

Create a rule like this:

Apply this rule after the message arrives
with : text/html in the message header
...

and then do what you want with with the message.

IMPORTANT: the search text must be ": text/html" minus the quotes but with a space between the colon and text/html.

Tom
0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 7056190
Nice suggestion about the rules wizard -- but it fails when running against a Microsoft Exchange server and the message comes from another person in the same site/org. (There is no internet header to search)
0
 
LVL 1

Expert Comment

by:tcav
ID: 7057102
True.

But blarts wants to block junk mail (and so do I.) It's unlikely that he (I'm presuming blarts is male) would want to block an html message that originated from his own Exchange Server.
0
 

Author Comment

by:blarts
ID: 7057429
Many thanks mate, that seemed to work perfectly. (Yes I am male!)

0
 

Author Comment

by:blarts
ID: 7057453
Many thanks for your help Neo. I implemented the code but need to get the folders name sorted out. I'm quite keen to get the hang of VBA coding so I'll be having a close look at the code you kindly sent me when I get back from holiday.
In the meantime the rules wizard solution seems to be working fine for what I need. I'd like to be able to show my appreciation for your help with points/grade but don't seem to be able to do so now having accepted tcav's answer. For what its worth, I thought it was A1. Cheers!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
Use email signature images to promote corporate certifications and industry awards.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now