Accessing an Outlook Folder through Automation

G

Guest

I am trying to have Access automate a procedure of moving an email in one
folder to another folder in Outlook. I know this can be done strictly through
Outlook, but I would like to have it automated with the rest of the procedure
I have already developed. I might have some problems with opening the second
folder too. I have used the Microsoft help library to come up with this
code....it doesn't seem to work....

Function moveemail()
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = _
myNameSpace.GetDefaultFolder(olFolderInbox)
Set myNewFolder = myFolder.Folders("FirstFolder")
Set myFirstItem = myNewFolder.Items.Item(1)
myFirstItem.Cut
Set myNewFolder = myFolder.Folders("SecondFolder")
myFirstItem.Paste
End Function
 

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