jlalande
asked on
How do I move an item from one folder to another in VBScript?
In a previous question, I asked and learned how to get a reference to the currently selected email. I've done some work with it and now I'd like to move it to another folder.
Can someone explain this process to me?
Thanks
Can someone explain this process to me?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This works fine if "Personal Mail" is a subfolder of "Inbox". The folder I would like to move my message is to a folder at the same level as "Inbox".
ASKER
OK.
I figured out how to get my folder. Instead of
Set myDestFolder = myInbox.Folders("Scratch")
I did
Set myDestFolder = myInbox.Parent.Folders("Sc ratch")
I figured out how to get my folder. Instead of
Set myDestFolder = myInbox.Folders("Scratch")
I did
Set myDestFolder = myInbox.Parent.Folders("Sc
ASKER
Thanks for your help.
URL: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaol10/html/olmthMove.asp
Set myOlApp = CreateObject("Outlook.Appl
Set myNameSpace = myOlApp.GetNameSpace("MAPI
Set myInbox = myNameSpace.GetDefaultFold
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("Personal Mail")
Set myItem = myItems.Find("[SenderName]
While TypeName(myItem) <> "Nothing"
myItem.Move myDestFolder
Set myItem = myItems.FindNext
Wend
If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.
Set myNameSpace = Application.GetNameSpace("
Set myInbox = myNameSpace.GetDefaultFold
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("Personal Mail")
Set myItem = myItems.Find("[SenderName]
While TypeName(myItem) <> "Nothing"
myItem.Move myDestFolder
Set myItem = myItems.FindNext
Wend