Solved

how can I block all emails with html content

Posted on 2002-05-27
10
157 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

740 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