Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook 2003 junk mail macro problem

Status
Not open for further replies.

Walter349

Technical User
Aug 16, 2002
250
0
0
BE
Can anyone tell me why the following code won't work?

Sub AddToJunkAndMove(objSel As Selection)
Dim objItem As Object
Dim objNS As NameSpace
Dim objDestFolder As MAPIFolder
Dim myOlApp As Outlook.Application

Set objNS = Application.GetNamespace("MAPI")
Set objDestFolder = objNS.Folders.Item("Mailbox - AAAAA, BBBBB").Folders.Item("Junk mail")

it always fails at the last line saying object could not be found. Yet the Mailbox and folder are correct
 
Not absolutely certain but try changing the line to :-
Code:
Set objDestFolder = objNS.Folders("Mailbox - AAAAA, BBBBB").Folders("Junk mail")

Regards
BrianB
Use CupOfCoffee to speed up all windows applications
================================
 
Thanks,

But that didn't work, it still comes up with Object not found. Highlighting the 'objDestFolder =' in the editor, shows as "objDestFolder = Nothing"

So it appears that it is not processing the DIM statements, but I cannot find out why.
 
A bit of a guess but try

Set objDestFolder = New MAPIFolder

before you try and assign any values to it????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top