Re: last solution

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Ok.

I don't have any issue when selecting several spams.

So today, I just add the address of one spam with the outlook menu and and then use the code which works quickly.

If I don't do like this, the set btn returns "nothing" and this even if I first add the adress with a Sendkeys, then cancel the sendkeys command in the code and enable the set Btn command for the next spam.

If I can find a solution, I'll keep you posted.

Bye

Michael Bauer avait énoncé :
Am Thu, 16 Mar 2006 10:47:53 +0100 schrieb Spectre:

For sure that´s no reason. If I select more than one item the button is
disabled, I can´t enable it.


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


By the way, I have microsoft CDO 1.21 and safeoutlook library as references in the library .
Perhaps an explanation for the "bug" on your pc.

Bye


Michael Bauer a pensé très fort :
Am Wed, 15 Mar 2006 13:34:41 +0100 schrieb Spectre:

Very interesting. On my machine(s) there´s no way to call the button´s
Execute if more than one mail is selected.

On which line do you get that error?

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


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

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

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


.



Relevant Pages

  • Re: last solution
    ... I just leave the focus on one of the spams or select several or all. ... If I swap to another soft and go back to outlook it carries on to work. ... Dim objInbox As MAPIFolder ... Dim response As String ...
    (microsoft.public.outlook.program_vba)
  • RE: creating outlook addin (mail merge)
    ... What is too complicated - the mail merge wizard options? ... chore selecting the contacts and clicking Mail Merge from the Tools menu? ... custom menu/toolbar button and put the Mail Merge button at a "higher level". ... Try Picture Attachments Wizard for Outlook! ...
    (microsoft.public.outlook.program_vba)
  • Re: Hiding the distribution list on an MS Outlook email message
    ... just by selecting contacts using Shift or Ctrl. ... Then in Outlook I use Tools/Mail Merge and change the various options, ... verify Form Letters is select and change the "Merge to" ... Microsoft Office MVP ...
    (microsoft.public.word.docmanagement)
  • Re: Missing Addrees Book in Outlook 2007
    ... the "Show this folder" was unchecked and ghosted so it could not ... I tried adding an additional address book and selecting the Outlook ... Delete the Outlook profile. ...
    (microsoft.public.office.misc)
  • Re: Custom Form One-Off Fix?
    ... You set this by selecting and opening ... version of Outlook you are using, there is a check box that is labeled ... e-mail format drop-down list box, one choice of which is RTF. ...
    (microsoft.public.outlook.program_forms)