View Single Post
  #2  
Old November 28th 06, 09:29 PM posted to microsoft.public.outlook.program_vba
JohnFenton
external usenet poster
 
Posts: 5
Default Outlook move to public folder


If no one here has any ideas for me, does anyone have a suggestion on
where to go to get help on this one?

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


Ads