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 - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Copy mail item to one folder and then move it to another folder



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 15th 06, 02:43 PM posted to microsoft.public.outlook.program_forms
LDMueller
external usenet poster
 
Posts: 53
Default Copy mail item to one folder and then move it to another folder

Hello,

I need to Copy an opened mail item to a folder name EmailCopy and then move
this same item to another folder named SavedEmail. I've searched the
newsgroup and was able to obtain the code for the "move part" (see code). I
just can't figure out how to make a copy of the mail item first.

Sub ToFolder()
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem, objReport _
As Outlook.ReportItem

Set objNS = Application.GetNamespace("MAPI")

Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Parent.Folders("SavedEmail")
'Assume this is a mail folder

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

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

For Each objReport In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objReport.Move objFolder
End If
End If
Next

Set objItem = Nothing
Set objReport = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub

Any assistance would be greatly appreciated!
Thanks!






Ads
  #2  
Old September 15th 06, 03:15 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Copy mail item to one folder and then move it to another folder

You must have missed the MailItem.Copy method:

Set objCopy = objItem.Copy
objCopy.Move objFolder

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"LDMueller" wrote in message ...
Hello,

I need to Copy an opened mail item to a folder name EmailCopy and then move
this same item to another folder named SavedEmail. I've searched the
newsgroup and was able to obtain the code for the "move part" (see code). I
just can't figure out how to make a copy of the mail item first.

Sub ToFolder()
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem, objReport _
As Outlook.ReportItem

Set objNS = Application.GetNamespace("MAPI")

Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Parent.Folders("SavedEmail")
'Assume this is a mail folder

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

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

For Each objReport In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objReport.Move objFolder
End If
End If
Next

Set objItem = Nothing
Set objReport = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub

Any assistance would be greatly appreciated!
Thanks!






 




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
Newbie question: How to copy an email item from inbox to a folder Marceepoo Outlook and VBA 1 November 1st 06 06:54 PM
After I've moved a note from Inbox to folder A, I can't move it to Folder B. [email protected] Outlook - General Queries 0 August 9th 06 10:46 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
Forwarding a mail from your sent item folder [email protected] Outlook - General Queries 0 March 22nd 06 06:13 PM
move mail to storage folder TuckerWheaten Outlook Express 4 January 18th 06 01:22 PM


All times are GMT +1. The time now is 12:30 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.