View Single Post
  #1  
Old January 15th 08, 01:23 AM posted to microsoft.public.outlook.program_vba
paul
external usenet poster
 
Posts: 197
Default Macro for Moving and Copying Mail

Hello,

I need to be able to select a message and have a copy go to one folder and
the original be moved to a second folder. One of these folders is in the
tree under the inbox the other is not. I found the following example that
someone else posted. I cannot get it to recognize the subfolder (HELP ME
HERE) spot. I have tried every formatting option I can think of. Assuming
the folder name is Miscellaneous, what should it look like in that variable
definition?

Second, how can I add a second part to copy it to the folder which is not in
the inbox tree?

Thank you so very very much!!!!

Sub HVR_Const()

On Error Resume Next

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.Parent.Folders(HELP ME HERE)
'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

Ads