A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook move to public folder



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old November 26th 06, 12:51 AM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 1
Default Outlook move to public folder

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

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help problems setting up rule to move email to a public folder Dab Outlook - General Queries 0 October 18th 06 01:09 AM
Copy mail item to one folder and then move it to another folder LDMueller Outlook - Using Forms 1 September 15th 06 03:15 PM
activate contact folder from public folder with "show this folder as email address book using a prf file Frankie K. Outlook - Using Contacts 7 July 25th 06 05:37 PM
How i export/copy/move messages in a public folder outlook 2003? Olatunde R. Adeniran Outlook - Using Contacts 1 May 3rd 06 06:51 PM
move to Outlook Folder Hlewis Outlook and VBA 9 March 27th 06 01:39 PM


All times are GMT +1. The time now is 06:50 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.