View Single Post
  #1  
Old February 25th 06, 08:24 AM posted to microsoft.public.outlook.program_vba
Dean
external usenet poster
 
Posts: 2
Default Using VBA code to move current message to a folder

Hello,
I want to automate the task of moving the currently open Outlook message into
a folder called "TEMP" I found a code example on this forum but have a few
questions. My variation of the code pasted below.

1) How do I dimension those object variables (note ????? in the code)?
2) Does the code look right?

Thanks in advance for any help you can provide.
Best Regards,
Dean

'---------------------------------------------------------------------------
Public Sub moveMsgToTEMP()
On Error GoTo Err_moveMsgToTEMP

'this sub moves the currently open message to the TEMP folder

Dim objApp As Outlook.Application
Dim olnBoxItems as ?????
Dim olNS As Outlook.NameSpace
'Dim objTargetFolder as ???????
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim objCurItem as ??????

Set oInBoxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set olNS = Item.Application.GetNamespace("MAPI")
Set objTargetFolder = objInbox.Folders("TEMP")
Set objCurItem = objCurItem.Move(objTargetFolder)
objCurItem.Save

Exit_moveMsgToTEMP:
Exit Sub
Err_moveMsgToTEMP:
MsgBox "sub moveMsgToTEMP " & Err.Description
Resume Exit_moveMsgToTEMP
End Sub
'---------------------------------------------------------------------------
Ads
 

Loans - Mobile Phone - Payday Loans - Proxy - Car Insurance