Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / December 2006

Tip: Looking for answers? Try searching our database.

Outlook move to public folder

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wodahsehtmai@yahoo.com - 26 Nov 2006 00:51 GMT
I keep getting a "one or more parameter values are not valid" on the
"objEmail.Move objFolder" line.

I can move it to an inbox sub folder without error, and I can manually
drag the item to the public folder without error.  Any ideas on what's
wrong here?  (I have publishing author client permisions on the
folder.)

John

Sub MoveSpam()
 Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
 Dim objNS     As Outlook.NameSpace, objItem   As Outlook.MailItem

 Set objNS = Application.GetNamespace("MAPI")
 'Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
 'Set objFolder = objInbox.Folders("Test")

 'Set objFolder = objNS.Folders("Public Folders").Folders("All Public
Folders").Folders("GFI  AntiSpam Folders").Folders("This is spam
email")
 For intX = 1 To objNS.Folders.Count
   If objNS.Folders.Item(intX).Name = "Public Folders" Then
     Set objFolder = objNS.Folders.Item(intX).Folders("All Public
Folders")
     Set objFolder = objFolder.Folders("GFI AntiSpam Folders")
     Set objFolder = objFolder.Folders("This is spam email")
     Exit For
   End If
 Next

 If objFolder Is Nothing Then
   MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
 End If

 If Application.ActiveExplorer.Selection.Count = 0 Then
   'Require that this procedure be called only when a message is
selected
   Exit Sub
 End If

 Set oSelection = Application.ActiveExplorer.Selection

 'intCount = oSelection.Count
 'For i = intCount To 1 Step -1
 '  Set objItem = oSelection.Item(i)
 '  If objFolder.DefaultItemType = olMailItem Then
 '    If objItem.Class = olMail Then
 '      objItem.Move objFolder
 '    End If
 '  End If
 '  'objItem.Copy objFolder
 'Next

 For intX = ActiveExplorer.Selection.Count To 1 Step -1
   Set objX = ActiveExplorer.Selection.Item(intX)
   If objX.Class = olMail Then
     Set objEmail = objX
     objEmail.Move objFolder
   End If
 Next

 'For Each objItem In Application.ActiveExplorer.Selection
 '  If objFolder.DefaultItemType = olMailItem Then
 '    If objItem.Class = olMail Then
 '      objItem.Move objFolder
 '    End If
 '  End If
 'Next

 Set objItem = Nothing
 Set objFolder = Nothing
 Set objInbox = Nothing
 Set objNS = Nothing
End Sub
JohnFenton - 28 Nov 2006 21:29 GMT
If no one here has any ideas for me, does anyone have a suggestion on
where to go to get help on this one?

> I keep getting a "one or more parameter values are not valid" on the
> "objEmail.Move objFolder" line.
[quoted text clipped - 72 lines]
>   Set objNS = Nothing
> End Sub
Ken Slovak - [MVP - Outlook] - 30 Nov 2006 14:37 GMT
I finally got some time to test your code here, after I created the correct
public folder tree. After declaring various undeclared variables the code
worked with no problems moving items to the public folder.

If it works for you manually dragging and dropping items into the public
folder then permissions shouldn't be a problem, but is there any way to
elevate your permissions to owner just to make sure it's not some odd
permissions issue?

Are any of the items you're attempting to move flagged as complete? That's
known to prevent moving until you clear the flag and then set it back again
after the move.

Although the code worked here see if it works for you when you call Move as
a function:
   Set objMoved = objEmail.Move(objFolder)

Any problems running any other macros?

What version of Outlook and Windows?

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> If no one here has any ideas for me, does anyone have a suggestion on
> where to go to get help on this one?
[quoted text clipped - 75 lines]
>>   Set objNS = Nothing
>> End Sub
JohnFenton - 02 Dec 2006 00:22 GMT
>>After declaring various undeclared variables the code

I wasn't getting any error messages on that but I think I have
everything declared now (VB is not my primary langauge and the code was
mostly picked up from other posts here.)  I'll put the updated code at
the end of this message.

>>elevate your permissions to owner

Done and I gave myself full admin and directory rights as well.  No
change.

>> Are any of the items you're attempting to move flagged as complete?

objItem.FlagStatus = olNoFlag

>>Set objMoved = objEmail.Move(objFolder)

Same error

>> Any problems running any other macros?

Not that I'm aware of.

>>> What version of Outlook and Windows?

Client:
Windows XP SP2
Outlook 2002 SP3

Server:
SBS2000 SP4
Exchange Server 2000 SP3

I am not an overly experienced exchange administrator, so it is
possible that there is something wrong in that setup.  It is mostly a
default SBS setup.

BTW the code works fine if I use:

 'Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
 'Set objFolder = objInbox.Folders("Spam")

Instead of the public folder.

Thanks for your help on this.

John

Revised Code:

Sub MoveSpam()
 Dim objFolder As Outlook.MAPIFolder
 Dim objInbox  As Outlook.MAPIFolder
 Dim objNS     As Outlook.NameSpace
 Dim objItem   As Outlook.MailItem
 Dim objMoved  As Outlook.MailItem

 Set objNS = Application.GetNamespace("MAPI")

 'Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
 'Set objFolder = objInbox.Folders("Spam")
 Set objFolder = objNS.Folders("Public Folders").Folders("All Public
Folders").Folders("GFI AntiSpam Folders").Folders("This is spam email")

 If objFolder Is Nothing Then
   MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
   Exit Sub
 End If

 If Application.ActiveExplorer.Selection.Count = 0 Then
   'Require that this procedure be called only when a message is
selected
   Exit Sub
 End If

 For intX = ActiveExplorer.Selection.Count To 1 Step -1
   Set objItem = ActiveExplorer.Selection.Item(intX)
   If objItem.Class = olMail Then
     'objItem.Move objFolder
     Set objMoved = objItem.Move(objFolder)
   End If
 Next

 Set objItem = Nothing
 Set objFolder = Nothing
 Set objInbox = Nothing
 Set objNS = Nothing
 Set objMoved = Nothing
End Sub

> I finally got some time to test your code here, after I created the correct
> public folder tree. After declaring various undeclared variables the code
[quoted text clipped - 104 lines]
> >>   Set objNS = Nothing
> >> End Sub
Ken Slovak - [MVP - Outlook] - 04 Dec 2006 16:55 GMT
If it works for Inbox it should work for the public folder. The code worked
for me for a public folder, so my only guess is it's some permissions issue.
The only move issue I'm aware of is the one with a flag marked complete, but
that would also affect moves to any other folder.

Still the same error message?

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

>>>After declaring various undeclared variables the code
>
[quoted text clipped - 87 lines]
>  Set objMoved = Nothing
> End Sub
JohnFenton - 05 Dec 2006 22:47 GMT
I posted a reply yesterday but it's not showing.

>>> Still the same error message?

Yes

Maybe I have something setup wrong on the server, but it's odd that I
can drag and drop the file into the same directory without any
problems.

John

> If it works for Inbox it should work for the public folder. The code worked
> for me for a public folder, so my only guess is it's some permissions issue.
[quoted text clipped - 102 lines]
> >  Set objMoved = Nothing
> > End Sub
Ken Slovak - [MVP - Outlook] - 06 Dec 2006 14:15 GMT
It's odd but the code works here so there's nothing intrinsically wrong with
it. I have no idea why it's not working for you.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> I posted a reply yesterday but it's not showing.
>
[quoted text clipped - 7 lines]
>
> John
JohnFenton - 08 Dec 2006 00:14 GMT
Thanks for checking this out for me.  I greatly appreciate it.

So I'm guessing if I want to resolve this the next step would be paid
tech support.  Or is there another place I should try first?

John

> It's odd but the code works here so there's nothing intrinsically wrong with
> it. I have no idea why it's not working for you.
[quoted text clipped - 18 lines]
> >
> > John
Ken Slovak - [MVP - Outlook] - 08 Dec 2006 18:43 GMT
Paid support is certainly an option. I'd also maybe explore setting up
different computers and/or virtual machines and see if things are the same
there. I'd also be playing with new profiles and possibly impersonating
other users to see how deep this problem goes. All I can say is running as
usual as admin and accessing the PF as owner the code worked for me. I also
ran it as my dog, who's an Exchange admin but a power user as a Windows
logon and who had publishing author rights on that PF.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Thanks for checking this out for me.  I greatly appreciate it.
>
> So I'm guessing if I want to resolve this the next step would be paid
> tech support.  Or is there another place I should try first?
>
> John
JohnFenton - 15 Dec 2006 02:05 GMT
>>Paid support is certainly an option. ...

You were right, I played around a bit more and found it.

PGP was interfering with it.  Shutting down PGP alowed it to move just
fine.  Now I have to see if I can work around the PGP problem.

John

> Paid support is certainly an option. I'd also maybe explore setting up
> different computers and/or virtual machines and see if things are the same
[quoted text clipped - 18 lines]
> >
> > John
Ken Slovak - [MVP - Outlook] - 15 Dec 2006 14:39 GMT
Interesting. Thanks for following up and letting us know it was PGP causing
the problem.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

>>>Paid support is certainly an option. ...
>
[quoted text clipped - 4 lines]
>
> John
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.