Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   adding at once all the email addresses of the spammers in the list of unwanted /unsollicited mails (http://www.outlookbanter.com/outlook-vba/7568-adding-once-all-email-addresses.html)

Spectre March 8th 06 11:44 AM

adding at once all the email addresses of the spammers in the list of unwanted /unsollicited mails
 
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
--
Spectre



Eric Legault [MVP - Outlook] March 8th 06 07:22 PM

adding at once all the email addresses of the spammers in the list
 
For versions prior to 2003, Outlook stores the list of blocked senders in
this file:

C:\Documents and Settings\user\Application Data\Microsoft\Outlook\Junk
Senders.txt

However, if you have Outlook 2003 you are out of luck. Otherwise, all you
need to do is append e-mail addresses to this file. A good way is to use the
TextStream object from the Microsoft Scripting Runtime Library (VBScript).

To get a handle to the selected e-mail, use the Explorer.Selection property.
For an open e-mail, use Inspector.CurrentItem. In both cases, get the value
of the MailItem.SenderEmailAddress. Note that accessing this property will
cause the security warning dialog to appear. See this link for more info:

Microsoft Outlook "Object Model Guard" Security Issues for Developers:
http://www.outlookcode.com/d/sec.htm

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Spectre" wrote:

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




Michael Bauer March 9th 06 07:49 AM

adding at once all the email addresses of the spammers in the list of unwanted /unsollicited mails
 
Am Wed, 8 Mar 2006 11:44:37 +0100 schrieb Spect

Because you cannot add multiple items at once via CommandBars this could be
a workaround:

1. You do have all selected items in ActiveExplorer.Selection. Keep that
list.
2. Create an empty folder
3. Switch to that folder
4. Copy one item from your selection into that folder. The item should be
the selected one now.
5. Call the CommmandBarButton.Execute (e.g. ID 9786 in OL 2003 for the
button "Add to blocked senders")
6. Delete that item from the folder
7. Go on with step 4 as long as the list contains items
8. No you could delete the created folder or keep it for the next time


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


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


Spectre March 9th 06 10:03 AM

adding at once all the email addresses of the spammers in the list of unwanted /unsollicited mails
 
hi,
thanks for your answers. I'll varry on with your ideas.

Bye


Spectre a pensé très fort :
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




Spectre March 11th 06 10:48 PM

adding at once all the email addresses of the spammers in the list of unwanted /unsollicited mails
 
Well, I have found a solution which is not the most professionnal one,
but it works.

I use the Sendkeys function . Using a French release of outlook, the
Senkeys "letters" must be most probably changed.

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

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


For I = 1 To oSelection.Count
Set olItem = oSelection.Item(I)
If oSelection.Count 0 Then ' si il ya des mails
junkMailAddress = olItem.SenderEmailAddress
If junkMailAddress "" Then
' *******************************
SendKeys "%SSB" ' here the changes to do
' *******************************
End If
End If
Next
End Sub

Spectre a émis l'idée suivante :
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




Spectre March 11th 06 11:28 PM

adding at once all the email addresses of the spammers in the list of unwanted /unsollicited mails
 
Better,
replace the Sendkeys line with :
Set Btn = Application.ActiveExplorer.CommandBars.FindControl (1, 9786)


Spectre a formulé la demande :
Well, I have found a solution which is not the most professionnal one, but it
works.

I use the Sendkeys function . Using a French release of outlook, the Senkeys
"letters" must be most probably changed.

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

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


For I = 1 To oSelection.Count
Set olItem = oSelection.Item(I)
If oSelection.Count 0 Then ' si il ya des mails
junkMailAddress = olItem.SenderEmailAddress
If junkMailAddress "" Then
' *******************************
SendKeys "%SSB" ' here the changes to do
' *******************************
End If
End If
Next
End Sub

Spectre a émis l'idée suivante :
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




Spectre March 12th 06 12:29 PM

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




Michael Bauer March 13th 06 08:37 AM

adding at once all the email addresses of the spammers in the list of unwanted /unsollicited mails
 
Am Sat, 11 Mar 2006 22:48:41 +0100 schrieb Spect

Unfortunately you´ve opened a new thread for the same topic. Please see my
answers in "last solution".

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


Well, I have found a solution which is not the most professionnal one,
but it works.

I use the Sendkeys function . Using a French release of outlook, the
Senkeys "letters" must be most probably changed.

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

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


For I = 1 To oSelection.Count
Set olItem = oSelection.Item(I)
If oSelection.Count 0 Then ' si il ya des mails
junkMailAddress = olItem.SenderEmailAddress
If junkMailAddress "" Then
' *******************************
SendKeys "%SSB" ' here the changes to do
' *******************************
End If
End If
Next
End Sub

Spectre a émis l'idée suivante :
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


Michael Bauer March 13th 06 08:49 AM

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


Spectre March 14th 06 10:10 PM

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





All times are GMT +1. The time now is 09:01 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-2006 OutlookBanter.com