View Single Post
  #4  
Old February 25th 06, 11:50 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Using VBA code to move current message to a folder

Am Sat, 25 Feb 2006 11:31:37 GMT schrieb Dean:

Sorry, olFolderInbox is correct.

What do you mean by "that doesn´t work", do you get an error?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Hi Michael,
Thanks for the advice. I'm still having a problem with this line:

Set InboxFolder = Application.Session.GetDefaultFolder(olInboxFolder )

I thought maybe it was a problem with "olInboxFolder" and tried the

constant
"olFolderInbox" but that didn't work. I'm also wondering if I need the

lack
of NameSpace and BoxItems instantiations is a problem. Thanks.


Michael Bauer wrote:
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)

Hello,
I want to automate the task of moving the currently open Outlook message

into
[quoted text clipped - 7 lines]
Best Regards,
Dean


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

[quoted text clipped - 21 lines]
Resume Exit_moveMsgToTEMP
End Sub


'---------------------------------------------------------------------------

Ads
 

Mortgages - Personal Loans - Mortgage Calculator - MPAA - Mortgages