Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you assign an outlook subfolder (under "inbox") to an object 1

Status
Not open for further replies.

Pack10

Programmer
Joined
Feb 3, 2010
Messages
495
Location
US
I'm working with an outlook group mailbox, no problem reading in emails from the inbox....but I now want to move them to another folder under the inbox after I am done processing....
I can't get the syntax correct -- here is my code that assigns the inbox fine...


Set MySPBAVInbox = objNS.Folders("Mailbox - SPB Verification").Folders("Inbox").Items
 
I think I wrote this for use with Outlook 98... so you might want to consider late binding over early...

Code:
Function moveMailItemDestination(ByVal OutDestFolder As Outlook.MAPIFolder, ByVal Outmailitem As Outlook.MailItem) As Boolean
On Error GoTo moveMailItemDestination_err
    moveMailItemDestination = False
    Outmailitem.Move OutDestFolder
    moveMailItemDestination = True
    
moveMailItemDestination_exit:
    Exit Function
moveMailItemDestination_err:
    MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "moveMailItemDestination"
    Resume moveMailItemDestination_exit
End Function


To get your subfolder...

Code:
Set MySPBAVInbox = objNS.Folders("Mailbox - SPB Verification").Folders("Inbox").Folders("SubFolderName")
 
Thank you I can't wait to try out the code
 
Worked like a charm. Perfect. I can't thank you enough.
 
lameid ... you have helped me a few times now, thank you sooooo much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top