Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how can I block all emails with html content

Posted on 2002-05-27
10
Medium Priority
?
164 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

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

Independent Software Vendors: 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

Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
Today as you open your Outlook, you witness an error message: “Outlook is using an old copy of your Outlook Data File…”. Probably, Outlook is accessing an old OST file.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

772 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