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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy mail items to a PST folder file using vba code

Status
Not open for further replies.

Gammachaser

Programmer
Apr 30, 2011
183
US

Outlook can be a strange beast...

This is a two step process, for some reason. First you make a copy, then you can move the copy. There is no command to do it in one step (at least that is how the process works when moving contact lists... I assume the syntax is similar for moving Mail Items.)

I declared a variable called olItem and a second variable called olCopy, then used Set olCopy = olItem.Copy followed by olCopy.Move olFolder. It worked for a mailing list, try it for a Mail Item.

Code:
(many other dim statements)
Dim olItem as Outlook.MailItem
Dim olCopy as Outlook.MailItem
Dim olFolder as Outlook.Folder

Set olFolder = [i]yourfoldername[/i]
Set olItem = [i]yourmailmessage[/i]
Set olCopy = olItem.Copy
olCopy.Move olFolder
...

Give it a try and let us know how it works.
 
Worked Thanks and I guess I will need to handle the sub-directories using a similar method. You are right they don't make it easy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top