473,769 Members | 8,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copying mail items from folder to another

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.Applica tion =
CreateObject("O utlook.Applicat ion")
Dim objNS As Outlook.NameSpa ce = objApp.GetNames pace("MAPI")
Dim objInbox As Outlook.MAPIFol der =
objNS.GetDefaul tFolder(Outlook .OlDefaultFolde rs.olFolderInbo x)

Dim objArchive As Outlook.MAPIFol der = objNS.Folders(" Personal
Folders").Folde rs("Archive").F olders("2005 Mail")

Dim oInbox As Outlook.Folders = objInbox.Folder s
Dim objItems As Outlook.Items = objInbox.Items
Dim oMessage As Outlook.MailIte m

intCount = objItems.Count

For i = intCount To 1 Step -1
oMessage = objItems.Item(i )
oMessage.Copy()
oMessage.Move(o bjArchive)
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.

Nov 21 '05 #1
0 971

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3034
by: Raghul | last post by:
hi I am having a problem. I want to copy a file from the folder and paste it or move it to another folder. Is it possible in python? Actually I need to implement this in the zope for my site. When I click any file it should move or copied to another folder in the same machine using zope. Thanks in advance.
3
1858
by: RitaG | last post by:
Hi. I know you can send an email using System.Web.Mail but other than using the Outlook object, is there another way to read the email in an Inbox. I'm currently reading the mail in an Inbox with the Outlook object. The program works fine when deployed on my pc but when deployed to another server I get a pop-up message saying "A program is trying to access mail addresses you have stored in Outlook".
3
4698
by: 21novembre | last post by:
Hi all, I made a question several days before to describe my strange trouble of mysqldump. But I still can't figour it out. Well, I just want to ask another question whether I could just backup my databases by copying the data folder to some place? Then if I meet some disaster, could I just copy the backup folder back to recover my databases? Thank you. Zh.y
8
17038
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts with '\\' it doesnt work and exception is thrown (for example: \\MyComputer\DestDirectory). Even if the first and the second directories are actually the same- the File.Copy() doesn't work. Is there any way to copy a file to a different computer?...
5
2353
by: TB | last post by:
Hi All: This news group is proving to be great help on my path towards mastering ASP.NET thanks to all of you helpful souls out there. I am looking forward to the day when I can contribute with a few ounces of hard-won knowledge as well. Meanwhile I have this (hopefully small) problem.
10
7838
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in 'to.txt' I specify where to copy it - After I read content of 'to.txt' I create one more subfolder named by current date and thats where everything gets to be copied
4
1405
by: tshad | last post by:
I have an old version of VS 2002 and want to make a copy of my Visual Studio project to another project with another name. In VS 2003, you can do it but there is no copy project command in VS 2002 (at least I can't seem to find it). Is there a way to do it? Thanks, Tom
11
1328
by: Zebra Code | last post by:
hi all i should copy the items of a combo to n other combos. it's not a cycle: With cboColor1 .Items.Add("ffffff") .Items.Add("cecece") ... .SelectedIndex = 0
13
10724
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to process the file. The appearance of the command file triggers the device to grab the original file. My problem is I don't want to write the command file to the device until the original file from the workflow has been copied completely. Since these...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.