Move message to folder

C

Carrie

I'm having some trouble writing code to move the currently
selected e-mail to a specific destination folder (an Inbox
subfolder named "Vendor"). I can get the following code to
work, but obviously I still have to pick the destination
folder:
Set oInboxItems = bjNS.GetDefaultFolder
(olFolderInbox).Items
Set olns = Item.Application.GetNamespace("MAPI")
Set objTargetFolder = Outlook.Session.PickFolder
Set objCurItem = oInboxItems.Item(1)
objCurItem.Move objTargetFolder

If I set the specific destination folder nothing happens:
Set oInboxItems = objNS.GetDefaultFolder
(olFolderInbox).Items
Set olns = Item.Application.GetNamespace("MAPI")
Set objTargetFolder = objInbox.Folders("Vendor")
Set objCurItem = oInboxItems.Item(1)
objCurItem.Move objTargetFolder

What am I doing wrong? Thanks in advance for any
suggestions!
 
J

John Blessing

Carrie said:
I'm having some trouble writing code to move the currently
selected e-mail to a specific destination folder (an Inbox
subfolder named "Vendor"). I can get the following code to
work, but obviously I still have to pick the destination
folder:
Set oInboxItems = bjNS.GetDefaultFolder
(olFolderInbox).Items
Set olns = Item.Application.GetNamespace("MAPI")
Set objTargetFolder = Outlook.Session.PickFolder
Set objCurItem = oInboxItems.Item(1)
objCurItem.Move objTargetFolder

If I set the specific destination folder nothing happens:
Set oInboxItems = objNS.GetDefaultFolder
(olFolderInbox).Items
Set olns = Item.Application.GetNamespace("MAPI")
Set objTargetFolder = objInbox.Folders("Vendor")
Set objCurItem = oInboxItems.Item(1)
objCurItem.Move objTargetFolder

What am I doing wrong? Thanks in advance for any
suggestions!


objCurItem .Move Application.GetNamespace("MAPI").Folders("Personal
Folders").Folders("Vendor")


--
John Blessing
http://www.LbeHelpdesk.com - Help Desk software at affordable prices
http://www.free-helpdesk.com - Completely free help desk software !
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
http://www.lbesync.com - Synchronize two Outlook Personal Folders
 
D

Dmitry Streblechenko

Change the line
objCurItem.Move objTargetFolder
to
set objCurItem = objCurItem.Move(objTargetFolder)
objCurItem.Save

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top