PC Review


Reply
Thread Tools Rate Thread

Copying mail items from folder to another

 
 
richardkreidl@northwesternmutual.com
Guest
Posts: n/a
 
      9th Aug 2005
I setup the code below to fire off from an Outlook rule when an email
arrives in the 'Inbox'. The code does work to a point. It does copy
email messages when they arrive in the 'Inbox' to the 'Archive->2005
Mail' folder. But, it seems to make copies of existing email in the
'2005 Mail' folder and I don't know why. My 'FOR NEXT" loop seems like
it's right, so I'm not sure why it's doing that.

Dim i As Integer
Dim count As Integer
Dim intCount As Integer

Dim objApp As Outlook.Application =
CreateObject("Outlook.Application")
Dim objNS As Outlook.NameSpace = objApp.GetNamespace("MAPI")
Dim objInbox As Outlook.MAPIFolder =
objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)

Dim objArchive As Outlook.MAPIFolder = objNS.Folders("Personal
Folders").Folders("Archive").Folders("2005 Mail")

Dim oInbox As Outlook.Folders = objInbox.Folders
Dim objItems As Outlook.Items = objInbox.Items
Dim oMessage As Outlook.MailItem

intCount = objItems.Count

For i = intCount To 1 Step -1
oMessage = objItems.Item(i)
oMessage.Copy()
oMessage.Move(objArchive)
Next

objNS.Logoff()
objApp = Nothing
objNS = Nothing
objItems = Nothing
oInbox = Nothing

I researched the Outlookcode.com site for a solution, but didn't really
find anything.

 
Reply With Quote
 
 
 
Reply

« Help | Parse Date »
Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2007 - Copying Sent Items to another Folder jminiman Microsoft Outlook Discussion 1 3rd Jan 2008 04:57 PM
Mail folder items mysteriously moved to Deleted Items aalrr Microsoft Outlook Installation 1 6th Dec 2007 09:47 PM
Messages are no longer copying to my sent items folder - help! =?Utf-8?B?YW1pbWloYXJ2?= Microsoft Outlook Discussion 0 30th Oct 2007 07:27 PM
Calendar Items - Copying enmasse to another folder via VBA Alan Microsoft Outlook VBA Programming 24 19th May 2004 04:55 AM
Moving Outlook Mail Items from Deleted Items to Public Folder Phil Greenway Microsoft Outlook VBA Programming 1 2nd Feb 2004 03:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:32 AM.