A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

adding at once all the email addresses of the spammers in the list of unwanted /unsollicited mails



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 15th 06, 06:51 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default last solution

Am Tue, 14 Mar 2006 22:10:38 +0100 schrieb Spect

I must correct myself: In OL 2003 it doesn´t work to add more than one item
at once (at least not in the German version), but in OL XP it seems that it
does.

But you're using the SenderEMailAddress and that is a feature of OL 2003.
I'm really interested in what happens if you select more than one item.

So far I don't know why you do have to delete an item first. The CommandBar
trick only works if there's really one item selected - but sometimes none is
selected.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Hi,

Thanks for your comments and your help.

For sure the " If oSelection.Count 0 Then" is not necessary!
For the other points :
- i don't select all the items to delete but only one, and it works (it
adds all the adresses in the blocked list and deletes all the mails in
the directory) but... only if I have first deleted a email in the
"ordinary way" and I don't understand why.

If you can help me on this....

Thanks an dbye



Après mûre réflexion, Michael Bauer a écrit :
Am Sun, 12 Mar 2006 12:29:10 +0100 schrieb Spect

Did you test that solution also for the case that really several items

are
selected?

As I wrote in your former thread, the button you refer to isn´t enabled

if
more than one item is selected.

Additionally the For Next loop doesn´t work if you do have more than one
item in the list and delete them. In that case your loop must count
backwards:

For i=oSelection.Count To 1 Step -1
...
Next

No errors but hopefully useful tipps for you:

For I = 1 To oSelection.Count
Set olItem = oSelection.Item(I)
If oSelection.Count 0 Then ' si il ya de s
mails


If the loop starts, i.e. if the execution goes on with the last line,

then
you do know already that Count 0. There´s no need to ask that again.

Set Btn =
Application.ActiveExplorer.CommandBars.FindControl (1, 9786)


The button is always the same. It slows down the execution if you set the
variable within the loop again and again.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Last release to add spam addresses in the list of blocked addresses. It
deletes also the spams.

Sub addSpamAdress() ' ajoute toutes les adresses des span à la liste
d'expéditeur indésirables
'On Error Resume Next

Dim olItem As Mailitem
Dim objInbox As MAPIFolder
Dim oSelection
Dim arc As Outlook.MAPIFolder
Dim junkMailAddress As String
Dim response As String

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderJunk)
Set oSelection = objInbox.Items

response = MsgBox("Your are going to add all the email addresses
to the Bocked Email list" & vbCrLf & _
"All emails will be deleted",
vbYesNoCancel, "Junk Mail")

If response = vbNo Or response = vbCancel Then
Exit Sub
Else
For I = 1 To oSelection.Count
Set olItem = oSelection.Item(I)
If oSelection.Count 0 Then ' si il ya de s
mails
junkMailAddress = olItem.SenderEmailAddress
If junkMailAddress "" Then

Set Btn =
Application.ActiveExplorer.CommandBars.FindControl (1, 9786)
Btn.Execute
olItem.Delete

End If
End If
Next
End If
End Sub



Spectre a formulé la demande :
Hi,

Even if spammers use often a new address for each spam they send, it is

not
always the case.

Hence, I am looking for a function which could add on one click all the
email addresses of the spams beeing in the unsollicited email folder

(a
translation from French for "courrier indésirable")! to the list of
unsollicited mail addresses.
I have tried to do it myself but I have been unable to find the name of
this list.

Thanks

  #2  
Old March 15th 06, 12:34 PM posted to microsoft.public.outlook.program_vba
Spectre
external usenet poster
 
Posts: 12
Default last solution

Hi,
I should have mentionned that I am using outlook 2003.

The olItem.Delete must be, of course, positionned after the
Btn.execute.

So, trying to be clearer,
- if have added, at first, one of the spam address of one mail with
the usual command bar button, the code works correctly.

I just leave the focus on one of the spams or select several or all.
The focus can also be on Contacts or Calendar and the code runs
without any problem.

If I swap to another soft and go back to outlook it carries on to work.

- but if I try to launch the code withtout having before add one
address "manually" and whatever I selected (one or several or all
spams), I have and error "object variable or block variable with and
undefinied with"

Bye


Michael Bauer vient de nous annoncer :
Am Tue, 14 Mar 2006 22:10:38 +0100 schrieb Spect

I must correct myself: In OL 2003 it doesn´t work to add more than one item
at once (at least not in the German version), but in OL XP it seems that it
does.

But you're using the SenderEMailAddress and that is a feature of OL 2003.
I'm really interested in what happens if you select more than one item.

So far I don't know why you do have to delete an item first. The CommandBar
trick only works if there's really one item selected - but sometimes none is
selected.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Hi,

Thanks for your comments and your help.

For sure the " If oSelection.Count 0 Then" is not necessary!
For the other points :
- i don't select all the items to delete but only one, and it works (it
adds all the adresses in the blocked list and deletes all the mails in
the directory) but... only if I have first deleted a email in the
"ordinary way" and I don't understand why.

If you can help me on this....

Thanks an dbye



Après mûre réflexion, Michael Bauer a écrit :
Am Sun, 12 Mar 2006 12:29:10 +0100 schrieb Spect

Did you test that solution also for the case that really several items are
selected?

As I wrote in your former thread, the button you refer to isn´t enabled if
more than one item is selected.

Additionally the For Next loop doesn´t work if you do have more than one
item in the list and delete them. In that case your loop must count
backwards:

For i=oSelection.Count To 1 Step -1
...
Next

No errors but hopefully useful tipps for you:

For I = 1 To oSelection.Count
Set olItem = oSelection.Item(I)
If oSelection.Count 0 Then ' si il ya de s
mails

If the loop starts, i.e. if the execution goes on with the last line, then
you do know already that Count 0. There´s no need to ask that again.

Set Btn =
Application.ActiveExplorer.CommandBars.FindControl (1, 9786)

The button is always the same. It slows down the execution if you set the
variable within the loop again and again.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Last release to add spam addresses in the list of blocked addresses. It
deletes also the spams.

Sub addSpamAdress() ' ajoute toutes les adresses des span à la liste
d'expéditeur indésirables
'On Error Resume Next

Dim olItem As Mailitem
Dim objInbox As MAPIFolder
Dim oSelection
Dim arc As Outlook.MAPIFolder
Dim junkMailAddress As String
Dim response As String

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderJunk)
Set oSelection = objInbox.Items

response = MsgBox("Your are going to add all the email addresses
to the Bocked Email list" & vbCrLf & _
"All emails will be deleted",
vbYesNoCancel, "Junk Mail")

If response = vbNo Or response = vbCancel Then
Exit Sub
Else
For I = 1 To oSelection.Count
Set olItem = oSelection.Item(I)
If oSelection.Count 0 Then ' si il ya de s
mails
junkMailAddress = olItem.SenderEmailAddress
If junkMailAddress "" Then

Set Btn =
Application.ActiveExplorer.CommandBars.FindControl (1, 9786)
Btn.Execute
olItem.Delete

End If
End If
Next
End If
End Sub



Spectre a formulé la demande :
Hi,

Even if spammers use often a new address for each spam they send, it is
not always the case.

Hence, I am looking for a function which could add on one click all the
email addresses of the spams beeing in the unsollicited email folder (a
translation from French for "courrier indésirable")! to the list of
unsollicited mail addresses.
I have tried to do it myself but I have been unable to find the name of
this list.

Thanks



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Spammers using Outlook to email-bomb sites David Wicks Outlook - General Queries 7 February 24th 06 08:32 PM
how to remove addresses from contacts list? me Outlook - Using Contacts 1 February 9th 06 07:38 AM
How do I find the number of email addresses in a distribution list Shockle Outlook - Using Contacts 1 January 30th 06 10:13 PM
message rules - can I import a list of email addresses? Alynn Baker Outlook Express 3 January 27th 06 02:36 PM
Adding Members to a Distribution List DeeW Outlook - Using Contacts 2 January 24th 06 08:20 PM


All times are GMT +1. The time now is 07:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.