Adding selected messages to blocked senders list

M

Mark Rae

Hi,

I'm trying to write a macro to add the sender of the selected messages in my
Inbox to the Blocked Senders list. I'm able to add the messages to the Junk
E-mail folder, but that does not appear to add their senders into the
Blocked Senders list. Here's what I'm using:

Sub DeleteJunk()

Dim objOutlook As New Outlook.Application
Dim objExplorer As Outlook.Explorer
Dim objSelection As Outlook.Selection
Dim objJunkFolder As Outlook.MAPIFolder
Dim intMessage As Integer
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objInbox = objNameSpace.GetDefaultFolder(olFolderInbox)
Set objExplorer = objOutlook.ActiveExplorer
Set objSelection = objExplorer.Selection
Set objJunkFolder = objNameSpace.Folders("Personal Folders").Folders("Junk
E-mail")
For intMessage = 1 To objSelection.Count
' need to add sender to Blocked Senders list
objSelection.Item(intMessage).Move objJunkFolder
Next intMessage

End Sub

Any assistance gratefully received.

Best regards,

Mark Rae
 
A

Andrew Cushen

Mark-

Unless you're set on a programmatic solution, you could
try what I did: assign the "Add to Junk Senders" action to
a button, and add that button to the Toolbar. Then, you
can just highlight the offending messages and click the
button, then delete the messages.

Although Outlook does get a little slow adding the senders
if your blocked senders list gets truly huge- like mine
has gotten! :-(
You might look into setting up a rule to search for "X-
Spam-Warning" in the message headers and deleting the
messages when those words are present, not to mention
looking into other blacklisting schemes. The rule I just
described prevents a lot of junk from ever getting to you.
Just put it as your first rule, and be sure to add
the "Stop processing more rules" option.

-Andrew
=======================
 
M

Mark Rae

Unless you're set on a programmatic solution, you could
try what I did: assign the "Add to Junk Senders" action to
a button, and add that button to the Toolbar. Then, you
can just highlight the offending messages and click the
button, then delete the messages.

Not possible, I'm afraid, unless I'm doing something seriously wrong
because, whenever more than one message is selected, the Add to Junk Senders
command (and, therefore, any custom button created from it) is disabled.
 
E

Eric Legault [MVP - Outlook]

It was far easier in Outlook versions previous to 2003 to manage this - you
could parse/edit the Junk Senders.txt file and away you go. OL 2003 however
manages the Blocked Senders list in the registry. You have two options:

- manipulate the registry keys to add blocked senders; the root hive is
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
Messaging Subsystem\Profiles\<username>; look for a sub-key similar to
0a0d020000000000c000000000000046. Within this key is another key (it is
001f041a for me) that has the list of blocked senders in binary format
- use CDO to retrieve a hidden message within your inbox called "Junk E-mail
Rule", which has a PR_MESSAGE_CLASS value of "IPM.ExtendedRule.Message".
The 0x0E9A property contains both Safe Senders and Blocked Senders though;
I'm not sure how the two are differentiated. You can try manipulating this
value to add/remove Blocked Senders, but I'm just guessing here.

I would go with the first option, as it doesn't require CDO. But it would
require advance knowledge of those key names.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top