Move email to directory folder then move email to another folder



Hello everyone,
I'm pretty new to VBA, sorry. But I need your help please. I'm moving
emails from a certain outlook folder "Incoming" to a directory folder
C:\\folder name. Then once the emails have moved, I need to move the emails
from "Incoming" to "Loaded" but only the ones that have moved to the
directory folder.

I have a script (see below) that will move the emails from the Incoming
folder to the directory just fine, but the second step, to then move those
emails to another outlook folder is not working. It doesn't error, its just
nothing. I'm sure I have the syntax incorrect, but just don't know how to
make it work.

Sub Export_CD_Requ(MyMail As MailItem)
'Exports the email into a folder as a txt file to import delimited line into
Dim Message As Outlook.MailItem
Dim myFolder
Dim myDstFolder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("Incoming")
'Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
strname = Format$(Now, "yyyymmdd_hhnnssmm")

For Each Message In myInbox.Items
Message.SaveAs "C:\MailMessages\" & strname & "_" & Message.Subject &
".txt", olTXT
Next Message

Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("Incoming")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("Loaded")
myFolder.MoveTo myDstFolder
End Sub

Any idea's anyone?

True Regards

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