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

Move item between folders



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old November 19th 08, 04:32 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Move item between folders

The declaration for colFolderItems needs to be at class level outside of the
startup procedure so it stays alive after that procedure ends. You'd also
need to have the items you're adding to the collection already instantiated
of course.

To instantiate a Class1 object do this:

Dim oClass As New Class1

You then need to set oClass (Class1) Folder and Items properties so those
should be Public:

' in Class1
Public WithEvents colItems As Outlook.Items
Public oFolder As Outlook.MAPIFolder

Now assuming you have the folders you want as oFolder1 and oFolder2 you'd do
this:

Set oClass.oFolder = oFolder1
Set oClass.colItems = oFolder1.Items

and repeat with a new instance of Class1 for each folder such as oFolder2.

Of course you'd need code to declare and instantiate all the folders you
want to monitor.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Nigel RS" wrote in message
...
Hi Ken
Thank you very much, but I am not sure I follow everything you said....

In Class1 module I have added the following.....

Private WithEvents colItems As Outlook.Items
Private oFolder As Outlook.MAPIFolder

Private Sub colItems_ItemAdd(Item As Object)
' test to show an action occurs
MsgBox "Mail: " & Item
End Sub

In ThisOutlookSession I have added......

Private Sub Application_Startup()
Private colFolderItems As New Collection
colFolderItems.Add Item:="RSM Data", Key:=CStr(1)
colFolderItems.Add Item:="RSS Data", Key:=CStr(2)
End Sub

What I am not sure about is how to intialize the class module??

I am sure it must be simple!

Cheers


 




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
Move sent mail to sub sub folders S1lverface Outlook and VBA 3 April 23rd 08 12:52 AM
objTargetFolder can't move item [email protected] Outlook - Using Forms 2 December 14th 06 11:14 PM
How to move focus/selection to a particular contact/item in Explor va Outlook and VBA 1 September 28th 06 11:31 PM
Let me move a Calendar item without sending an update Winter Outlook - Calandaring 1 May 29th 06 10:01 PM
Item Move event AtulSureka Outlook and VBA 1 February 24th 06 01:33 PM


All times are GMT +1. The time now is 11:38 PM.


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.