Am Sat, 25 Feb 2006 08:24:56 GMT schrieb Dean:
Very good Dean, just a little messed up :-)
You need a ref onto the currently opened item. If you want to handle every
item types with then you can use a declaration As Object. Else, if there are
MailItems only you could declare the variable As MailItem.
Then you need a ref onto the target folder. Every folder is the same object
type of and is called MapiFolder.
If the target folder is a subfolder of the Inbox then get a ref onto the
Inbox (itself, not its Items) first then onto a child of it.
In code:
Dim objCurItem as Object
Dim InboxFolder as Outlook.MapiFolder
Dim TargetFolder as Outlook.MapiFolder
' currently opened item
Set objCurItem = Application.ActiveInspector.CurrentItem
' Inbox folder
Set InboxFolder = Application.Session.GetDefaultFolder(olInboxFolder )
' Subfolder of the Inbox
Set TargetFolder = InboxFolder.Item("TEMP")
' Move the message
Set objCurItem = objCurItem.Move(TargetFolder)
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
--
www.vbOffice.net --
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
'---------------------------------------------------------------------------